REAPER KB

Action binding

reascript_prose/reascript-howto-action-binding · kind=reference

Action binding

Query MIDI/OSC/mouse-wheel input values when a script is bound to a controller or the mouse wheel.

Kind: how-to

You can query various contextual information about the script, at runtime, using get_action_context()/ reaper.get_action_context() (sorry, no Python support) . You can retrieve MIDI/OSC/mouse-wheel/trackpad input values when the script is bound to MIDI/OSC controllers (both absolute and relative modes are supported), or to the mouse-wheel/trackpad.

Here is a basic Lua example which monitors received MIDI/OSC input values:

function run()
  is_new,name,sec,cmd,rel,res,val = reaper.get_action_context()
  if is_new then
    reaper.ShowConsoleMsg(name .. "\nrel: " .. rel .. "\nres: " .. res .. "\nval = " .. val .. "\n")
  end
  reaper.defer(run)
end

function onexit()
  reaper.ShowConsoleMsg("<-----\n")
end

reaper.defer(run)
reaper.atexit(onexit)

Other sections in this document