|
|
|
01-24-2019, 08:01 AM
|
#1
|
Human being with feelings
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,031
|
Triggering custom actions using AutoHotkey with Postmessage?
Does anyone know how to trigger custom actions in Reaper from AutoHotkey using Postmessage?
For normal actions it is easy, you can use:
PHP Code:
ReaperLove(ID)
{
global
Postmessage,0x111,ID,,,ahk_class REAPERwnd
return
}
|
|
|
01-24-2019, 08:45 AM
|
#2
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
You can't, you'd have to write a script in reaper to convert them first then save to say a file that your AHK script could read. For the fun of it I slapped this together real quick just to see if it was possible...
https://forum.cockos.com/showpost.ph...2&postcount=22
|
|
|
01-24-2019, 09:32 AM
|
#3
|
Human being with feelings
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,031
|
Thanks for replying, but this is for sure not something I would use. My goal is always making things simpler, not the opposite. For now I am just triggering the Reaper hotkey bindings.
This is what I am using right now, in AutoHotkey. Hitting Alt-Enter toggles between hackey trackey and hackey patterns, you could use any hotkey you like. As I could not achieve this by internal methods, for now I am using this solution. I guess even lua or python should be able to close windows based on the window title. Then a .lua or .py action could replace this.
This is all not ideal now, but better than nothing.
PHP Code:
!Enter::
IfWinExist, Hackey Trackey
{
WinClose, Hackey Trackey
; start patterns here
; Notify("start patterns here")
Send ^1 ; requirement: Ctrl+1 is mapped in Reaper to Hackey Patterns
}
IfWinExist, Hackey Patterns
{
WinClose, Hackey Patterns
; start tracker here
; Notify("start tracker here")
Send ^2 ; requirement: Ctrl+2 is mapped in Reaper to Hackey Trackey or tracker.lua
}
return
|
|
|
01-24-2019, 09:46 AM
|
#4
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
You could probably write that in a lua script using js_ReaScriptAPI extension, I don't understand AHK, but commands are probably pretty similar,.. something like
Code:
hwnd = reaper.JS_Window_Find("Hackey Trackey", true)-- find window by title bar text
if hwnd then -- close the window
reaper.JS_WindowMessage_Post(hwnd, "WM_CLOSE", 0,0,0,0)
else -- do something else like launch a script,..
reaper.Main_OnCommand(cmd_id, 0)
end
|
|
|
01-24-2019, 01:48 PM
|
#5
|
Human being with feelings
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,031
|
Thanks a lot, almost there. Is there a way to let the .lua script wait for some time before next command, for example waiting for 500ms or half second? I want to activate the newly opened hackey patterns window, and for this I guess I need to wait a bit, at least worth a try.
This is what I have so far, the idea is having a replacement for above AutoHotkey, using .lua + js_ReaScriptAPI extension:
PHP Code:
hwnd = reaper.JS_Window_Find("Hackey Trackey", false)-- find window by title bar text
if hwnd then -- close the window
reaper.JS_WindowMessage_Post(hwnd, "WM_CLOSE", 0,0,0,0)
reaper.Main_OnCommand(41898,0) -- ReaScript: Close all running reaScripts
-- open hackey patterns, _RSe2f8fd29750dcbc0703bc1d661132968c93e3ab4, Script: HackeyPatterns_exec.lua
command_id = reaper.NamedCommandLookup("_RSe2f8fd29750dcbc0703bc1d661132968c93e3ab4")
reaper.Main_OnCommand(command_id,0)
hwnd2 = reaper.JS_Window_Find("Hackey Patterns", false)-- find window by title bar text
if hwnd2 then
reaper.JS_WindowMessage_Post(hwnd2, "WM_ACTIVATE", 0,0,0,0)
end
else
hwnd2 = reaper.JS_Window_Find("Hackey Patterns", false)-- find window by title bar text
if hwnd2 then -- close the window
-- reaper.JS_WindowMessage_Post(hwnd2, "WM_CLOSE", 0,0,0,0)
reaper.Main_OnCommand(41898,0) -- ReaScript: Close all running reaScripts
-- open hackey trackey, _RS4975f174de39cf66dae73112193ceb783c92adfb, Script: tracker.lua
-- command_id = reaper.NamedCommandLookup("_RS4975f174de39cf66dae73112193ceb783c92adfb")
-- reaper.Main_OnCommand(command_id,0)
end
end
Last edited by TonE; 01-24-2019 at 01:58 PM.
|
|
|
01-25-2019, 11:34 AM
|
#6
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by TonE
Thanks a lot, almost there. Is there a way to let the .lua script wait for some time before next command, for example waiting for 500ms or half second?
|
If you do need a delay then maybe use a runloop and check elapsed time each pass, something like,..
Code:
function timer()
local elaspsed = reaper.time_precise() - init_time
if elaspsed >= wait then
reaper.ShowConsoleMsg("Times Up!" .. '\n')
--< secondary code here >--
return -- and exit!
else -- runloop
reaper.ShowConsoleMsg(tostring(elaspsed) .. '\n')
reaper.defer(timer)
end
end
--< initial code here >--
-- wait X seconds, then run other code
wait = 0.500
init_time = reaper.time_precise()
timer()
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 06:28 AM.
|