Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER General Discussion Forum

Reply
 
Thread Tools Display Modes
Old 12-17-2013, 05:37 AM   #1
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default How to assign a shortcut key to an action with a script?

Hello!

I would like to make a custom toolbar with buttons that could assign the SAME keyboard key to DIFFERENT actions depending on which toolbar button is pressed.

For example, let's say that my custom toolbar has two buttons: A and B.

When I press button A, <TAB> is assigned to "move to next transient in item" and <SHIFT>+<TAB> is assigned to to "move to previous transient in item".

When I press button B, <TAB> is assigned to "move to next stretch marker in item" and <SHIFT>+<TAB> is assigned to to "move to previous stretch marker in item".

Is this possible? How can this be achieved? With ReaScript?

Thanks!
amagalma is offline   Reply With Quote
Old 12-18-2013, 08:59 AM   #2
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Any ideas?
amagalma is offline   Reply With Quote
Old 12-18-2013, 04:34 PM   #3
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

I think using ReaScript would work for this, but there's no convenient way to choose the actions involved, they would need to be set up with hand written configuration files or so...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 12-18-2013, 06:03 PM   #4
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

I did a set of ReaScripts that accomplishes this, if you are interested, I can upload them somewhere. (You would need Python installed and set up in Reaper for the scripts to work.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 12-18-2013, 07:08 PM   #5
Jeffsounds
Human being with feelings
 
Jeffsounds's Avatar
 
Join Date: Feb 2013
Location: Northeast Michigan
Posts: 3,460
Default

Xenakios, you know this Reaper stuff far better than I do, but couldn't he create an action for this? There is an action to move to next/previous transient and there is an action to go to next/previous stretch marker. Couldn't he just create the action and assign it to the button's he desires?

Like I said, you know this stuff far better than I...
__________________
"TV has become nothing more than a Petri dish where this country grows its idiots." -Dr. John Becker
My First CD On Spotify - Side O' The Highway
Jeffsounds is offline   Reply With Quote
Old 12-18-2013, 07:57 PM   #6
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Jeffsounds View Post
Xenakios, you know this Reaper stuff far better than I do, but couldn't he create an action for this? There is an action to move to next/previous transient and there is an action to go to next/previous stretch marker. Couldn't he just create the action and assign it to the button's he desires?

Like I said, you know this stuff far better than I...
He wants a way to trigger different actions from the same shortcut keys, depending on which "group" is active(*). I don't think that is possible in any other way than using ReaScript or an extension plugin at the moment.

My solution with ReaScript does not switch the actual shortcut keys for the actions, as that is not possible easily from Python scripts. (And if I recall right, not even from C++ extension plugins.) Instead I have additional ReaScript actions that indirectly call the original Reaper actions depending on which action group has been set active. So, he would assign the Tab and Shift+Tab shortcuts to these new indirect actions and other shortcut keys or toolbar buttons for "switch active action group to a/b etc".

(*) ie,

Group A : Tab is "next transient", Shift+Tab is "previous transient"
Group B : Tab is "next stretch marker", Shift+Tab is "previous stretch marker"
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 12-18-2013, 09:32 PM   #7
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

you can also call AutoHotkey scripts from reaper python as well...

I use this to do exactly what the OP is talking about, I have a toolbar that switches the behavior of the 4th mouse button.

install is a bit finicky. (let me see if I can find that thread... spk knows this a lot better than I do...)

info here; http://forum.cockos.com/showthread.php?t=108171

Xenakios, your version of this might be easier, can we take a peek. SO far there isn't a way to unload a AHK script, or at least not that we've figured out. (although I hacked it together anyway.)

Last edited by James HE; 12-18-2013 at 09:38 PM.
James HE is offline   Reply With Quote
Old 12-18-2013, 10:20 PM   #8
Jeffsounds
Human being with feelings
 
Jeffsounds's Avatar
 
Join Date: Feb 2013
Location: Northeast Michigan
Posts: 3,460
Default

Quote:
Originally Posted by Xenakios View Post
He wants a way to trigger different actions from the same shortcut keys, depending on which "group" is active(*). I don't think that is possible in any other way than using ReaScript or an extension plugin at the moment.

My solution with ReaScript does not switch the actual shortcut keys for the actions, as that is not possible easily from Python scripts. (And if I recall right, not even from C++ extension plugins.) Instead I have additional ReaScript actions that indirectly call the original Reaper actions depending on which action group has been set active. So, he would assign the Tab and Shift+Tab shortcuts to these new indirect actions and other shortcut keys or toolbar buttons for "switch active action group to a/b etc".

(*) ie,

Group A : Tab is "next transient", Shift+Tab is "previous transient"
Group B : Tab is "next stretch marker", Shift+Tab is "previous stretch marker"
See? I told you you know more about this stuff than I do!
__________________
"TV has become nothing more than a Petri dish where this country grows its idiots." -Dr. John Becker
My First CD On Spotify - Side O' The Highway
Jeffsounds is offline   Reply With Quote
Old 12-19-2013, 05:05 AM   #9
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Wow! Thank you all so much for your help!!

Quote:
Originally Posted by Xenakios View Post
I did a set of ReaScripts that accomplishes this, if you are interested, I can upload them somewhere. (You would need Python installed and set up in Reaper for the scripts to work.)
Oh, please do!

Quote:
Originally Posted by Xenakios View Post
My solution with ReaScript does not switch the actual shortcut keys for the actions, as that is not possible easily from Python scripts. (And if I recall right, not even from C++ extension plugins.) Instead I have additional ReaScript actions that indirectly call the original Reaper actions depending on which action group has been set active. So, he would assign the Tab and Shift+Tab shortcuts to these new indirect actions and other shortcut keys or toolbar buttons for "switch active action group to a/b etc".

(*) ie,

Group A : Tab is "next transient", Shift+Tab is "previous transient"
Group B : Tab is "next stretch marker", Shift+Tab is "previous stretch marker"
That is a perfect solution! I have already downloaded and installed Python 3.3.3! Looking forward to your scripts! Thank you so much!
amagalma is offline   Reply With Quote
Old 12-19-2013, 01:31 PM   #10
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Here's the script package :

http://www.xenakios.liitin.net/publi...ion_groups.zip

Inside are several .py files, which you should import into Reaper as new ReaScript actions (in the actions window), except not these files :

activate_action_group_helper.py
execute_action_helper.py

Those scripts can't be used by Reaper as actions, they contain shared implementation details for the other much shorter/simpler scripts.

Sorry for the terse instructions here, I'll explain more if you end up having problems using these. (I've set up the defaults more or less like the original poster wanted, but other actions can also be set up by editing the script files or the JSON configuration file, including extension plugin actions using named command lookup.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 12-19-2013, 02:16 PM   #11
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

You are amazing! I have tried it and it works like a dream! You even went a step further creating 4 groups of 4 actions each!

I opened all the scripts and although I cannot understand each line (since I have no idea on programming), I understood how it works! You even explain it in the "activate_action_group_helper.py"! All is clear!

I can't stress enough how grateful I am to you! If you ever find yourself in Athens (Greece), please let me invite you to a dinner!
amagalma is offline   Reply With Quote
Old 12-19-2013, 04:04 PM   #12
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by amagalma View Post
I have tried it and it works like a dream!

I can't stress enough how grateful I am to you! If you ever find yourself in Athens (Greece), please let me invite you to a dinner!
Nice it's working for you! I am not sure when/if I could use your offer, but I am definitely hoping to visit Greece and Athens at some my point in my life...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 12-26-2013, 11:35 PM   #13
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Do come! The Greek islands are especially beautiful!

...I have another question!.. I made a SWS Cycle action that cycles between "activate action group a" and "activate action group b" and assigned it to a button on my custom toolbar. All is working fine!
My question has to do with the visuals.. Currently, my button is named "Tab Setting" and if I place my mouse on it the tooltip says "Tab Setting" too. If I click the button, then a rectangle appears in the upper left part of the screen saying either "Action group: transients" or "Action group: Stretch markers". But this rectangle appears only for a fraction of a second!

Is there any way to make my button "tell" me what is activated? Or to make this rectangle with the information appear longer? (like 1-2 seconds for example)
amagalma is offline   Reply With Quote
Old 12-27-2013, 08:01 AM   #14
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by amagalma View Post
Is there any way to make my button "tell" me what is activated? Or to make this rectangle with the information appear longer? (like 1-2 seconds for example)
Unfortunately there isn't a good way to do that kind of feedback using the Reaper API. The short lived tooltip was the only hack I could think of, to give some non-intrusive feedback of what action group was activated. It certainly isn't ideal. But the alternatives would have been a modal message dialog(*) box (yuck!) or popping up the ReaScript message console. The latter at least wouldn't have been modal but I decided it perhaps would be too distracting too...

(*) That is, you would have to manually dismiss the dialog before you could do anything else in Reaper.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 12-27-2013, 08:35 AM   #15
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

No problem then! It was just a matter of improving things aesthetically/visually. It works fine as it is and the work is done!

Thank you again for all the help!
amagalma is offline   Reply With Quote
Old 12-27-2013, 10:03 AM   #16
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 2,173
Default

Maybe the SWS Exclusive Toggle action could be incorporated as a visual indicator? I use it in my own little version.
FnA is offline   Reply With Quote
Old 12-28-2013, 04:02 AM   #17
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

What action is that? I can't find it. How do you use it? What does it do?
amagalma is offline   Reply With Quote
Old 12-29-2013, 04:33 PM   #18
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 2,173
Default

Maybe there's none available by default. To get them you go into your S&M ini file and edit it for the number that you want. It's not as bad as it sounds. There's some instructions right in the file. Just backspace out the number which I guess is probably 0 in your file, and change it to whatever you want. Unless otherwise noted in there, max is 99 actions for a lot of those things.

I have not really studied what's going on in this thread. My deal is more of an Autohotkey thing than a Reaper thing. Another option which works for me is to include a SWS slot action for changing the theme.

You want Reaper to be off when you're doing this.

If you turn one on two goes off, etc.

Reread your first post. This would probably have to be a seperate button from the one you use to turn any thing on or off with. Just an indicator to be included in whatever macro you trigger the process with.

Last edited by FnA; 12-30-2013 at 05:07 AM.
FnA is offline   Reply With Quote
Old 10-20-2021, 11:45 PM   #19
More Sound
Human being with feelings
 
More Sound's Avatar
 
Join Date: Apr 2021
Location: Syracuse, NY
Posts: 103
Default

Hello - I know I'm late to the game here on an old thread, but I would LOVE to get ahold of the "action groups" code from Xenakios. Anyone have the code or similar code?

TIA
__________________
Jason "Jocko" Randall
More Sound Recording Studio
Syracuse, NY
More Sound is offline   Reply With Quote
Old 02-03-2022, 08:45 AM   #20
Gaett
Human being with feelings
 
Join Date: Jun 2021
Posts: 27
Default

Up,
similar topic I have recently started
https://forum.cockos.com/showthread.php?t=262542
Gaett is offline   Reply With Quote
Old 02-03-2022, 01:21 PM   #21
Fergler
Human being with feelings
 
Fergler's Avatar
 
Join Date: Jan 2014
Posts: 5,207
Default

In a script, could you maybe have a function that checks what state the toolbar button is in before it runs one of a user selected action ID? Then the shortcut runs the script, which makes the choice between the two actions.
Fergler is offline   Reply With Quote
Old 02-09-2022, 12:06 AM   #22
Gaett
Human being with feelings
 
Join Date: Jun 2021
Posts: 27
Default

Hi Fergler,
sorry for the delay of my reply. I think it won't work for my need.
I have a midi fader controller and i use the CC1 to "Track: Set volume for last touched track (MIDI CC/OSC only)" as action.
But in another way I want to use the same fader controller and CC1 to use the CC1 function in my instrument VST.
The problem is in that way, when I move CC1, it both play with the dynamic of my cello (for example), and it moves the volume of the track.

I don't really know how to separate this because the function is always running. But, with a script that could delete the Hotkey of my "Track: Set volume for last touched track (MIDI CC/OSC only)", CC1 will return to its primary function
Gaett is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.