|
|
|
11-20-2018, 01:33 AM
|
#1
|
Human being with feelings
Join Date: Sep 2016
Location: Toronto
Posts: 744
|
Scripts to open/close another script
Is it possible to make scripts that don't toggle another script, but specifically just open or close it? Most scripts don't report their state to REAPER, so I can't use the Cycle Action Editor for this.
|
|
|
11-20-2018, 08:03 AM
|
#2
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
By opening you mean, open it in the Reascript-IDE?
|
|
|
11-20-2018, 09:54 AM
|
#3
|
Human being with feelings
Join Date: Apr 2014
Posts: 4,171
|
Yes - would definitely like to be able to close a specific script from another script.
|
|
|
11-20-2018, 10:27 AM
|
#4
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by lb0
Yes - would definitely like to be able to close a specific script from another script.
|
You could possibly close a script window by sending it a close window message using js_ReaScriptAPI extension, this quick test works here (on Windows 7),..
Code:
hWnd = reaper.JS_Window_Find("ReaNoir v2.07", true) -- find window by title bar text
if hWnd ~=nil then
reaper.JS_WindowMessage_Post(hWnd, "WM_CLOSE", 0,0,0,0)
end
Last edited by Edgemeal; 11-20-2018 at 10:33 AM.
|
|
|
11-20-2018, 03:30 PM
|
#5
|
Human being with feelings
Join Date: Sep 2016
Location: Toronto
Posts: 744
|
Quote:
Originally Posted by mespotine
By opening you mean, open it in the Reascript-IDE?
|
I mean running the script, not opening in IDE
|
|
|
11-20-2018, 03:30 PM
|
#6
|
Human being with feelings
Join Date: Sep 2016
Location: Toronto
Posts: 744
|
Quote:
Originally Posted by Edgemeal
You could possibly close a script window by sending it a close window message using js_ReaScriptAPI extension, this quick test works here (on Windows 7),..
Code:
hWnd = reaper.JS_Window_Find("ReaNoir v2.07", true) -- find window by title bar text
if hWnd ~=nil then
reaper.JS_WindowMessage_Post(hWnd, "WM_CLOSE", 0,0,0,0)
end
|
This works great. Thanks edgemeal! How would one modify this to run the script if it isn't open?
|
|
|
11-20-2018, 04:20 PM
|
#7
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by Arthur McArthur
This works great. Thanks edgemeal! How would one modify this to run the script if it isn't open?
|
Try something like,...
Code:
hWnd = reaper.JS_Window_Find("ReaNoir v2.07", true)-- find window by title bar text
if hWnd ~=nil then -- close window
reaper.JS_WindowMessage_Post(hWnd, "WM_CLOSE", 0,0,0,0)
else -- launch ReaNoir script
cmd = reaper.NamedCommandLookup('_RS3b8d8b2140a32d0bfaa6eda3bd21b06d0b7b215b')
if cmd > 0 then
reaper.Main_OnCommand(cmd, 0)
else
reaper.MB("Invalid script Command ID!","ERROR",0)
end
end
NOTE: To close a window on Mac and Windows use this instead,..
Code:
reaper.JS_Window_Destroy(hwnd)
Last edited by Edgemeal; 05-10-2019 at 09:34 AM.
|
|
|
11-20-2018, 10:07 PM
|
#8
|
Human being with feelings
Join Date: Sep 2016
Location: Toronto
Posts: 744
|
Awesome, thanks again! I ended up using this to just launch the script if it isn't open (works for docked scripts too which is great):
Code:
hWnd = reaper.JS_Window_Find("Reaticulate", true)-- find window by title bar text
if hWnd ~=nil then --
else -- launch script
cmd = reaper.NamedCommandLookup('_RSbe259504561f6a52557d2d1c64e52ef13527bf17')
if cmd > 0 then
reaper.Main_OnCommand(cmd, 0)
else
reaper.MB("Invalid script Command ID!","ERROR",0)
end
end
|
|
|
11-21-2018, 08:02 AM
|
#9
|
Human being with feelings
Join Date: Apr 2014
Posts: 4,171
|
Quote:
Originally Posted by Edgemeal
You could possibly close a script window by sending it a close window message using js_ReaScriptAPI extension, this quick test works here (on Windows 7),..
Code:
hWnd = reaper.JS_Window_Find("ReaNoir v2.07", true) -- find window by title bar text
if hWnd ~=nil then
reaper.JS_WindowMessage_Post(hWnd, "WM_CLOSE", 0,0,0,0)
end
|
Thanks Edgemeal, Yes - that would work. I'm very keen to maintain full OS independence - so would need to look into that - although I think most of JS's API's are cross-platform. And I'd worry if the script was docked - what then - does it still work? (I know - I should just try it - but I'm assuming a docked window becomes part of the containing window and so this would likely not work in that case)?
|
|
|
11-21-2018, 09:43 AM
|
#10
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
You'll have to test it but I think JS coded the APIs to work with docking tabs also, for example my reset vu meter script seems to be work just fine on docked fx also.
|
|
|
11-21-2018, 05:44 PM
|
#11
|
Human being with feelings
Join Date: Apr 2014
Posts: 4,171
|
Quote:
Originally Posted by Edgemeal
You'll have to test it but I think JS coded the APIs to work with docking tabs also, for example my reset vu meter script seems to be work just fine on docked fx also.
|
oooh - I'll give it a go then - thank you.
|
|
|
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 02:25 AM.
|