Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 09-18-2018, 02:36 PM   #1
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default API: AddRemoveReaAction(), AddRemoveShortcut() and additions to AddRemoveReaScript()

We already have AddRemoveReaScript(), so I can add successfully ReaScripts.
But sometimes, I would like to add actions and shortcuts as well.


So I would love to suggest API-functions:

AddRemoveReaAction() as well as AddRemoveShortcut()

Code:
integer = reaper.AddRemoveReaAction(boolean add, integer sectionID, string action_command_ids, string description, string ActionCommandID, boolean commit)

works like AddRemoveReaScript but adds actions instead of scripts.
action_command_ids - the ActionCommandIDs/CommandIDs as comma-separated-csv-string
description - holds the description shown in the Action-List
ActionCommandID - the action-command-id, under which this action can be called. Function returns 0, if ActionCommandID is already given(add=true)

Code:
integer = reaper.AddRemoveShortcut(boolean add, integer modifier, integer key_midi, string action_command_id, integer sectionID, boolean commit)

adds shortcuts to your script, as added into reaper-kb.ini.

integer modifier and integer key_midi - the modifier and the key/midinotes used as shortcut.
string ActionCommandID - action-command-id, to which this shortcut is associated. Function returns 0, if ActionCommandID is already given(add=true)

Especially adding/removing shortcuts would be helpful, as I would love to have different keyboard-layouts, that I would love to change using a script, like having F1 to F4 for 4 different Keyboard-Layouts for different usecases.
Easy change of keyboard-layouts is something some video-editing-programs have, like AVID. If that would be codeable, this would be great.
Even if it only supports the modifier/key/midinote-integer-numbers set in the kb.ini it would be helpful, as I already documented all these shortcut-codes for further usage. They could be referenced, then.

The usecase for adding actions:
When I write a script, I sometimes would love to give alternative versions of this script. In many cases, this could be done quite easily by adding actions, that do additional things before/after my script.
I would love to automatically add these actions from within my script, so users would not need to create them by hand, as this is unhandy or difficult for new users.
So adding actions "from the backdoor" would be a nice addition to adding scripts.


Edit:
Regarding AddRemoveReaScript(), I would love to see additional parameters for description and the action-commandid itself. I prefer having human-readable action-command-ids in my scripts and I would love to add useful descriptions automatically as well for easier understanding, what my script does.
If these parameters are set to nil, the function works, like it already does.
If an ActionCommandID is already existing and add=true, the function returns 0.
Meo-Ada Mespotine is offline   Reply With Quote
Old 09-20-2018, 09:53 PM   #2
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

You can generate new script duplicating your custom action and add it with AddRemoveReaScript(). Adding/changing shortcuts from API would be indeed good (although dangerous in bad hands).

Quote:
I prefer having human-readable action-command-ids in my scripts
From somewhere in 5.0 alpha prereleases I rememeber it was said custom stuff ID`s are automatically hash-of-filepath based.
mpl is offline   Reply With Quote
Old 09-23-2018, 07:29 AM   #3
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Yeah, but this is no action like the one I can add in the action-list "editor". And it's not editable by the action-list-"editor", only in the IDE, which I would love to avoid to force using, if my action is not intended for users inexperienced in coding.

The ActionCommandID can be changed in the reaper-kb.ini (I documented the way to do it) and we at ultraschall use this heavily. It clears up code very much. If you do not need to use "_RS3748UI87jkndzis687698NNUIo68" but rather "_This_Is_My_Script_Number_1", your code becomes much more readable.

I could also add the stuff into the reaper-kb.ini, but I would need a chance to reload the kb.ini-file while Reaper is running. If I want to change shortcuts on the fly using a shortcut, I can't be forced restarting Reaper all the time.
Meo-Ada Mespotine is offline   Reply With Quote
Old 10-12-2018, 06:09 AM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

After thinking about it for some more days, it would probably be much easier to do the key-shortcuts, by adding functions:

boolean retval = reaper.ImportKeyMaps(string keymapsfilename, boolean reset_to_factory_defaultshortcuts_first)

and

boolean retval = reaper.ExportKeyMaps(string output_keymapsfilename)

that would work, as if I had imported or exported ReaperKeyMaps in the action-list.

This would easily allow changing shortcut-keys per script, so I can use individual keymaps for every usecase I have.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 05-27-2019, 03:01 AM   #5
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

BumpyMcBumpy
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 09-10-2020, 10:13 PM   #6
Archie
Human being with feelings
 
Archie's Avatar
 
Join Date: Oct 2017
Location: Russia
Posts: 366
Default

I would also like to see a function 'AddRemoveShortcut()' or something similar to change the shortcut by script
__________________
=================================
ReaPack| Archie-ReaScript: Discussion | Donate | Donate2 | Donate3 | PayPal |
Archie 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 07:00 AM.


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