Old 07-06-2019, 01:10 PM   #1
vitalker
Human being with feelings
 
vitalker's Avatar
 
Join Date: Dec 2012
Posts: 4,787
Default Script: Shortcuts presets

The script originally has appeared on RMM Rusian forum in 2016. I've just translated the instruction. The authors are Aleksandr_Oleynik and https://rmmedia.ru/members/21334/.
The concept is following:

1. Choosing and reserving some keys (F1-F12 in our case), which actions will be changeable depending on our needs. Example: first preset is for markers 1-12, second preset is for selecting tracks 1-12 etc.

2. Changing the preset of keys actions using other keys or toolbar buttons

3. Indicating the current preset with a LED.

How it looks:

As an example, we'll consider two presets. One for markers 1-12 and another one for selecting tracks 1-12. You can see on the GIF - we choose the preset on the toolbar and pressing F1-F12. You can switch presets using both toolbar or shortcuts.


How to install:
1. There are two Lua scripts, which can be used for creating your own templates.
! Go to marker 1-12 (Changeble Key Preset).lua
! Select track 1-12 (Changeble Key Preset).lua
2. Move them to \AppData\Roaming\REAPER\Scripts or <REAPER root folder>\Scripts and import inside REAPER: Actions → Action List → ReaScript → Load...
3. After first run new 12 scripts will be created for any of two scripts: ChanKey01.lua ... ChanKey12.lua. Import them (see point 2) and assign F1-F12 keys to these scripts.
4. Creating your own presets: make a copy of any of the main scripts (! Go to marker 1-12 (Changeble Key Preset).lua or ! Select track 1-12 (Changeble Key Preset).lua), rename it, change the content and import into REAPER.


If you are planning to use internal actions, choose ! Go to marker 1-12 (Changeble Key Preset).lua as a template. In other cases use ! Select track 1-12 (Changeble Key Preset).lua.

How to find action Command ID:

5. Assign created preset script to toolbar buttons or keys/MIDI controller.

Download here: https://stash.reaper.fm/v/36670/shortcut presets.zip
__________________
Quote:
Originally Posted by Sexan View Post
Make a thread "F%#! you Reaper! I quit!" to get more views and feedback since these kind of threads get much more traction
SoundCloudFR: True Non-destructive GLUEAll the REAPER names

Last edited by vitalker; 07-07-2019 at 01:26 AM.
vitalker is online now   Reply With Quote
Old 07-06-2019, 10:18 PM   #2
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 2,465
Default

You'd probably better to use some kind of configuration setup custom script for to not force users edit the code.

Also would be nice to share it with ReaPack. I imagine it will costs you 1 metapackage shared 12 assignable scripts.

Of course native implementation of modifying reaper-kb.ini would be still better.

Also link doesn`t work.

Edit: just overviewed source code here, so it write files then run them...Not really good idea, hmmm let me try to implement it more user friendly.
__________________
SoundCloud | MPL Scripts discussion | ReaPack | Donate

Last edited by mpl; 07-06-2019 at 10:52 PM.
mpl is offline   Reply With Quote
Old 07-07-2019, 01:28 AM   #3
vitalker
Human being with feelings
 
vitalker's Avatar
 
Join Date: Dec 2012
Posts: 4,787
Default

Quote:
Originally Posted by mpl View Post
You'd probably better to use some kind of configuration setup custom script for to not force users edit the code.

Also would be nice to share it with ReaPack. I imagine it will costs you 1 metapackage shared 12 assignable scripts.
Thanks, I've fixed the link and I am not an author.
__________________
Quote:
Originally Posted by Sexan View Post
Make a thread "F%#! you Reaper! I quit!" to get more views and feedback since these kind of threads get much more traction
SoundCloudFR: True Non-destructive GLUEAll the REAPER names
vitalker is online now   Reply With Quote
Old 07-07-2019, 12:08 PM   #4
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 2,465
Default

Here is preliminary ReaPack-compatible metapackaged version of this with additional custom setup scripts for 4 sets of actions:

Code:
-- @description ChangableHotKeys
-- @version 1.0
-- @author Oleynik, diggidon, MPL
-- @website http://forum.cockos.com/showpost.php?p=2154840&postcount=1
-- @metapackage
-- @provides
--    [main] . > Oleynik_ChangableHotKeys Enable shortcuts for set 1.lua
--    [main] . > Oleynik_ChangableHotKeys Enable shortcuts for set 2.lua
--    [main] . > Oleynik_ChangableHotKeys Enable shortcuts for set 3.lua
--    [main] . > Oleynik_ChangableHotKeys Enable shortcuts for set 4.lua
--    [main] . > Oleynik_ChangableHotKeys Setup shortcuts for set 1.lua
--    [main] . > Oleynik_ChangableHotKeys Setup shortcuts for set 2.lua
--    [main] . > Oleynik_ChangableHotKeys Setup shortcuts for set 3.lua
--    [main] . > Oleynik_ChangableHotKeys Setup shortcuts for set 4.lua
--    [main] . > Oleynik_ChangableHotKeys Run shortcuts action 1.lua
--    [main] . > Oleynik_ChangableHotKeys Run shortcuts action 2.lua
--    [main] . > Oleynik_ChangableHotKeys Run shortcuts action 3.lua
--    [main] . > Oleynik_ChangableHotKeys Run shortcuts action 4.lua
--    [main] . > Oleynik_ChangableHotKeys Run shortcuts action 5.lua
--    [main] . > Oleynik_ChangableHotKeys Run shortcuts action 6.lua
--    [main] . > Oleynik_ChangableHotKeys Run shortcuts action 7.lua
--    [main] . > Oleynik_ChangableHotKeys Run shortcuts action 8.lua
--    [main] . > Oleynik_ChangableHotKeys Run shortcuts action 9.lua
--    [main] . > Oleynik_ChangableHotKeys Run shortcuts action 10.lua
--    [main] . > Oleynik_ChangableHotKeys Run shortcuts action 11.lua
--    [main] . > Oleynik_ChangableHotKeys Run shortcuts action 12.lua
-- @changelog
--    + init
  
  local extst_section = 'ChangableHotKeys'
-------------------------------------------------------------------------    
  for key in pairs(reaper) do _G[key]=reaper[key]  end 
  function msg(s)  if not s then s= 'nil' end if type(s) == 'boolean' then if s then s = 'true' else  s = 'false' end end ShowConsoleMsg(s..'\n')  end 
-------------------------------------------------------------------------  
  function Enable_shortcuts_for_setX(id)
    SetExtState( extst_section, 'current_set', id, true )
  end
------------------------------------------------------------------------- 
  function Setup_shortcuts_for_setX(id)
    local param_str = ''
    local key_str = ''
    local key_cnt = 12
    for i = 1, key_cnt do
      param_str = param_str..GetExtState( extst_section, 'set'..id..'key'..i)..','
      key_str = key_str..'Assigned action '..i..','
    end
    key_str = key_str..'extrawidth=200'
     ret, str = GetUserInputs(extst_section..'for set '..id, key_cnt, key_str, param_str)
    if ret then 
      str =  str.. ','
      t = {}
      for val in str:gmatch('(.-,)') do t[#t+1] = val:sub(0,-2) end 
      if #t == key_cnt then
        for i = 1, key_cnt do
          SetExtState( extst_section, 'set'..id..'key'..i, t[i], true)
        end
      end
    end
  end 
  -------------------------------------------------------------------------  
  function Run_shortcuts_action(id)
    local current_set = GetExtState( extst_section, 'current_set')
    if not current_set or (current_set and current_set == '') then current_set = 1 else current_set = tonumber(current_set) end
    local actionID = GetExtState( extst_section, 'set'..current_set..'key'..id)
    if actionID and actionID ~= '' then 
      if tonumber(actionID) then actionID = tonumber(actionID) end
      Main_OnCommand(NamedCommandLookup(actionID), 0) 
    end
  end
-------------------------------------------------------------------------  
  local script_name = ({reaper.get_action_context()})[2]
  if script_name:match('Enable shortcuts for set %d+') then 
    Enable_shortcuts_for_setX(tonumber(script_name:match('Enable shortcuts for set (%d+)')))
   elseif script_name:match('Setup shortcuts for set %d+') then
    Setup_shortcuts_for_setX(tonumber(script_name:match('Setup shortcuts for set (%d+)')))
   elseif script_name:match('Run shortcuts action %d+') then
    Run_shortcuts_action(tonumber(script_name:match('Run shortcuts action (%d+)')))
  end
If you want to only overwrite first set then ! Select track 1-12 (Changeble Key Preset).lua would looks like this:
Code:
id = 1
t= {  "_SWS_SEL1",
      "_SWS_SEL2",
      "_SWS_SEL3",
      "_SWS_SEL4",
      "_SWS_SEL5",
      "_SWS_SEL6",
      "_SWS_SEL7",
      "_SWS_SEL8",
      "_SWS_SEL9",
      "_SWS_SEL10",
      "_SWS_SEL11",
      "_SWS_SEL12"
      }
      
for i = 1, 12 do SetExtState( 'ChangableHotKeys', 'set'..id..'key'..i, t[i], true) end
SetExtState( 'ChangableHotKeys', 'current_set', id, true )
__________________
SoundCloud | MPL Scripts discussion | ReaPack | Donate

Last edited by mpl; 07-07-2019 at 12:22 PM.
mpl 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 08:58 AM.


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