Advanced Actions Management: Import and Export Toolbars Buttons linked to Scripts, Change Script Path and Name

customActionsScriptsNames
Obsolete
This article is obsolete. Since a previous recent REAPER version, scripts imported into REAPER can now have the same command ID if they were imported through the same path under User Resources / Scripts folder. These command ID will work on all OS. So, the original problem answered by this article can be prevented if you use consistent files structures for your scripts on all your work stations.
Warning
This method is a hack. It had for purpose to showcase a problem, and our desire to find a way to overcome it. Cockos developpers personnaly recommand to not abuse of it, and even to not use it at all. A better approach to scripts libraries loading is in the radar. I leave it online as a demo.
Note
This tutorial is focused on scripts, but it works with custom actions too !

Facts:

  • When importing a script into REAPER, it’s command ID is randomly generated.
  • When creating a custom actions, it’s command ID is randomly generated.
  • Menu actions are defined by command ID.
  • You can’t rename an actions related to a script, or change this script path.

Question: How to share toolbars with a scripts and custom actions on it (without sharing full config) ? You can’t just import the scripts and the menu settings, as the command ID will not match.
Few days ago, my answer to that was simple: “you can’t”. And for toolbars full of scripts, as my Text Item Formatting toolbar, this was a major issue.

We speak about that on the forum, without finding solution, so I wrote a deep feature request, related to that: Better Scripts Management: Importation, Folders, ID, Deletion.

The truth: it is not that we cannot do it. We just didn’t found how !

I was playing with config file (it was fun, trust me) when an idea came to me. And after some tests, I came up with a way to solve that problem !

You already have waiting to much for this, so here is how to do it !

Tutorial

This is a silent video. You can still work on REAPER or listen to the last album of your favorite artist while looking at it !

Reminder
To put your scripts in the default script folder, use Show REAPER resource path in explorer/finder… in the REAPER Options menu to find it !

Here is a recap of the tutorial:

Creation of the ReaperKeyMap

  1. Put scripts in default user scripts folder (you can have subfolders)
  2. Open REAPER
  3. Import scripts via the Actions window
  4. Export scripts infos (ReaperKeyMap) via Action window
  5. Edit ReaperKeyMap action COMMAND_ID in a text/code editor (see details on that below)
  6. Delete keyboards shortcuts infos. It look like this : KEY 1 87 _a07c4dfa374aa74aa7636c3e92e2be85 32060
  7. Delete obsolete scripts in REAPER (those you just changed the command ID)
  8. Import scripts via ReaperKeyMap into REAPER with Actions window
  9. Build the Menu
  10. Export the Menu
  11. Share the menu, the scripts, and the ReaperKeyMap

Modifications and Importation

  1. Put scripts in default user scripts folder
  2. Open REAPER
  3. Import scripts (ReaperKeyMap) into REAPER
  4. Import Menu

The importation workflow with ReaperKeyMap allows you to rename scripts and change their path. I don’t know if the way subfolder path is written is OS-Dependant.

You can modify a ReaperKeyMap in a code editor to change some infos, like Script Command_ID, Script Path and Action name.

Here is what the keymap code looks like:

The first string is COMMAND_ID, the second is action name, and third is path relative to user script default folder.

Speaking about COMMAND_ID, I don’t know yet all we have to know to make a good one, but based on what I was from SWS extensions, I will advice you to keep it concise, without spaces, and write it in UPPERCASE. Of course, it has to be unique, so add your pseudo as prefix may be a way to be sure that your COMMAND_ID will be unique.

Important
A proper COMMAND_ID is critical. I Don’t know what are there limites but I have bad surprises with actions names so here as general guidelines based on my experiences:

  • Letters, numbers and underscore (_) only
  • Letters Uppercase
  • Don’t start with an underscore (_): it will be added automatically
  • No more than 34 characters (it seems to work with more but this I cannot be sure)
  • Use a distinct initial as prefix (from your pseudo for eg), to be sure that your command IDs will be unique

Command_ID seem to be more flexible than that but I can’t test every possibility (aka call from other scripting language, different OS, toolbars etc…), so keep it simple.

You have more freedom with action name but you have to be careful, for the same reason. There is only one critical rule:

Important
Action name — Script or Custom Action — must start by Custom: .

It will be modified into Script: if it is linked to a script.

This leads to another way to import script, useful if you want a action name different from the file name, of if you want to important lots of scripts at the same time, without create duplicate (in case of you already have some of them in your config).

Reminder
If you want to rename a script, you will have to delete the previous related action first.

Path (EDIT: 2015-07-15)

The REAPER keymap is different on Windows and on Mac.

If you script is in a subfolder, the path will loke like this when exported from Windows :

Mac version would be like this :

If you want to share your Actions list, you may need to create a WIn and a Mac version of the reaper keymap, and search/replace all the slashes/anti-slashes accordingly.

Conclusion

Thanks to this methods, we will be able to share toolbars full of scripts.

It may be the perfect time to write my next-gen subtitling with REAPER tutorial ! 😀

  • jeffos

    I’m sorry, but although this trick looks like it works, I don’t think it is a good idea…
    It’s super-non-future-proof and breaks some SWS features already…

  • Hi, thanks for your advice !
    The only SWS action I found that doesn’t support this custom ID is the Dump Action list type of action.
    Meanwhile, it is the only trick I found for sharing custom actions with scripts, scripts calling other scripts and toolbars that link to scripts, in a consistent way between users, because of the non random ID.
    Sure, it looks a bit “hacky”… Did I missed something ?