Old 12-02-2009, 06:51 AM   #1
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 9,382
Default Reaper/custom/extension action command IDs and strings

This will be of interest only to extension developers, ReaScript authors, and AutoHotKey users.

For context:

Reaper native actions are the set of actions that appear in the action dialog (press the ? key) for all users.

Reaper custom actions are action lists (essentially macros) that are created by users, and appear at the top of the action list as "Custom: actionname".

ReaScript allows users to create scripts in Python or Perl that do many of the same things that extensions can do. ReaScripts can be loaded as actions and appear in the action dialog as "Custom: scriptname".

Reaper extensions are compiled add-ins created by developers (such as the redoubtable SWS and Xenakios) to add functionality to Reaper. Regular users download and install the extensions, and the extended functions then appear in the action dialog as (for example) "SWS: actionname".

AutoHotKey is a 3rd-party application, nothing to do with Reaper, that can be used to create macros that send commands directly to windows on your screen.

Every native, custom, and extension action in Reaper has a command ID. This is a unique number that identifies the action. ReaScript users can invoke any action via functions like RPR_Main_OnCommand and RPR_MIDIEditor_OnCommand. SWS extension users can use the command IDs in SWS marker actions. AHK users can invoke any action by sending the command ID to the Reaper window.

No other users will ever care about command IDs. If you don't fit any of the descriptions in the previous paragraph (or if you don't understand any of this) then you don't need to worry about it and can happily go back to recording whatever awesome music you were just about to record.

You can see command IDs for each action by scrolling to the right in the action dialog. Only Reaper native actions have command ID numbers that never change. These are the only command ID numbers that are completely safe to use in any of these contexts.

Custom, ReaScript, and extension actions are assigned command ID numbers when Reaper starts up. This is because Reaper doesn't know until it loads how many non-native actions will be added. Therefore, these command ID numbers can change from run to run. For example if you add or delete a custom action, ReaScript, or extension dll, or if the extension itself is updated, then any or all of the non-native command ID numbers can change. The ID numbers themselves can't be relied on unless the set of non-native commands never changes.

Non-native actions are stored with a command ID string that Reaper uses at load time to assign unique command ID numbers. The command ID string never changes and can be relied on.

ReaScript authors should use RPR_NamedCommandLookup to convert non-native command ID strings to numbers within the script. Otherwise, the script isn't guaranteed to always work.

Unfortunately AHK users don't have a choice, AHK doesn't have anything to do with Reaper so it doesn't have any way to look up command ID numbers. Whenever non-native actions change, AHK scripts that use non-native actions may break and will need to be updated.
schwa is offline   Reply With Quote
Old 12-03-2009, 05:54 AM   #2
Shan
Human being with feelings
 
Shan's Avatar
 
Join Date: Mar 2007
Location: Vancouver
Posts: 2,277
Default

Great overview and explanations. Maybe this is worth a sticky in the developer forum for future reference?

Shane
__________________
"Music should be performed by the musician not by the engineer."

Michael Wagener 25th July 2005, 02:59 PM
Shan is offline   Reply With Quote
Old 12-05-2009, 01:04 AM   #3
sfzgeek
Human being with feelings
 
sfzgeek's Avatar
 
Join Date: Feb 2009
Location: Dunedin, New Zealand
Posts: 204
Default

I appreciate the explanation and understand the reasoning behind the changes. Makes sense to me.

That said, how do I work out the command ID for a ReaScript now? Sorry if it was explained and I missed it but I'm stuck! I have an important AutoHotkey script that triggers a ReaScript using SendMessage but I can't figure out how to get it to work on the latest builds.

Any help appreciated!
__________________
My rawk band: The Hidden Venture.
sfzgeek is offline   Reply With Quote
Old 12-05-2009, 01:59 AM   #4
sfzgeek
Human being with feelings
 
sfzgeek's Avatar
 
Join Date: Feb 2009
Location: Dunedin, New Zealand
Posts: 204
Default

False alarm. A bit of futzing around and I worked out how to find what I was after. My script works again now! Thanks anyway.
__________________
My rawk band: The Hidden Venture.
sfzgeek is offline   Reply With Quote
Old 05-02-2012, 07:25 AM   #5
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

Since REAPER 4.20, this information has also become relevant to those using REAPER's OSC (control surface) support, as also noted in this thread.
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline   Reply With Quote
Old 01-05-2013, 01:51 PM   #6
Xane002
Human being with feelings
 
Join Date: Aug 2009
Posts: 82
Default

Quote:
Originally Posted by Banned View Post
Since REAPER 4.20, this information has also become relevant to those using REAPER's OSC (control surface) support, as also noted in this thread.
^^^^+1
Xane002 is offline   Reply With Quote
Old 03-07-2013, 05:33 PM   #7
Cyaoeu
Human being with feelings
 
Join Date: Aug 2010
Location: Sweden
Posts: 10
Default

Shouldn't this be stickied or put in the ReaScript forum or something? It took me a while to find this information...
Cyaoeu is offline   Reply With Quote
Old 03-08-2013, 03:36 AM   #8
gofer
-blänk-
 
gofer's Avatar
 
Join Date: Jun 2008
Posts: 11,011
Default

Agreed and moved . This thread was created before the advent of a ReaScript subforum and apparently slipped through the cracks. Thanks for the heads up.
gofer is offline   Reply With Quote
Old 02-26-2015, 09:36 AM   #9
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 4,419
Default

I don't understand why the command id has to change for reascripts. It makes it difficult to distribute a script that needs to launch another reascript.

Shouldn't the command id be a hash of the script's file name so it only changes if the file name changes?

Or at least... can we NamedCommandLookup with a filename parameter instead?
__________________
HeDaScripts for REAPER | VIP Donations
heda is offline   Reply With Quote
Old 11-17-2017, 01:43 PM   #10
elijahlucian
Human being with feelings
 
Join Date: Dec 2006
Posts: 51
Default

Quote:
Originally Posted by heda View Post
I don't understand why the command id has to change for reascripts. It makes it difficult to distribute a script that needs to launch another reascript.

Shouldn't the command id be a hash of the script's file name so it only changes if the file name changes?

Or at least... can we NamedCommandLookup with a filename parameter instead?
agreed. its impossible to systemize a script with this limitation.
elijahlucian is offline   Reply With Quote
Old 11-17-2017, 02:04 PM   #11
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 7,292
Default

I think this has changed meanwhile.

v5.1 - November 15 2015
+ ReaScript: use deterministic command ID string when adding scripts as actions
nofish is offline   Reply With Quote
Old 11-17-2017, 02:40 PM   #12
elijahlucian
Human being with feelings
 
Join Date: Dec 2006
Posts: 51
Default

Quote:
Originally Posted by nofish View Post
I think this has changed meanwhile.

v5.1 - November 15 2015
+ ReaScript: use deterministic command ID string when adding scripts as actions
how can i add a custom commandID?

I am havingg trouble triggering it via OSC with the long string
elijahlucian is offline   Reply With Quote
Old 11-18-2017, 05:41 PM   #13
elijahlucian
Human being with feelings
 
Join Date: Dec 2006
Posts: 51
Default

Quote:
Originally Posted by nofish View Post
I think this has changed meanwhile.

v5.1 - November 15 2015
+ ReaScript: use deterministic command ID string when adding scripts as actions
yeah I don't think this is the case...

I copied my script from one computer to another, and they both have separate commandIDs
elijahlucian is offline   Reply With Quote
Old 11-18-2017, 05:48 PM   #14
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 1,488
Default

The command ID remain the same from one computer the next if (from observation) the path (relative to the resource directory if it's inside, absolute otherwise) including the filename is identical.
cfillion 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 10:03 AM.


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