|
| 1 | +-- @description Toggle show monitoring FX chain |
| 2 | +-- @author Edgemeal |
| 3 | +-- @version 1.02 |
| 4 | +-- @changelog |
| 5 | +-- Fix for MacOS - Now closes window. |
| 6 | +-- Show monitor if docked but not the selected tab. |
| 7 | +-- Additional checking to identify target window. |
| 8 | + |
| 9 | +function FindWindow(window_titles, child_id, child_must_visible) |
| 10 | + local arr = reaper.new_array({}, 128) |
| 11 | + for i = 1, #window_titles do |
| 12 | + local title = reaper.JS_Localize(window_titles[i], 'common') |
| 13 | + reaper.JS_Window_ArrayFind(title, true, arr) |
| 14 | + local handles = arr.table() |
| 15 | + for j = 1, #handles do |
| 16 | + local hwnd = reaper.JS_Window_HandleFromAddress(handles[j]) -- window handle |
| 17 | + local child_hwnd = reaper.JS_Window_FindChildByID(hwnd, child_id) -- child handle |
| 18 | + if child_hwnd then -- child control found |
| 19 | + if child_must_visible and not reaper.JS_Window_IsVisible(child_hwnd) then -- child must be visible |
| 20 | + return nil |
| 21 | + else |
| 22 | + return hwnd |
| 23 | + end |
| 24 | + end |
| 25 | + end |
| 26 | + end |
| 27 | +end |
| 28 | + |
| 29 | +function Main() |
| 30 | + local t = {'FX: Monitoring','FX: Monitoring [BYPASSED]'} -- titlebar text(s) to find |
| 31 | + local hwnd = FindWindow(t, 1076, true) -- 1076 = child id to find, true = child must be visible, i.e., docked but tab not selected. |
| 32 | + if not hwnd then |
| 33 | + reaper.Main_OnCommand(41882, 0) -- View: Show monitoring FX chain |
| 34 | + else -- close fx monitor window |
| 35 | + reaper.JS_Window_Destroy(hwnd) -- Tested Win7 & MacOS 10.12. |
| 36 | + end |
| 37 | +end |
| 38 | + |
| 39 | +if not reaper.APIExists("JS_Window_Find") then |
| 40 | + reaper.MB("js_ReaScriptAPI extension is required for this script.", "Missing API", 0) |
| 41 | +else |
| 42 | + Main() |
| 43 | +end |
| 44 | + |
| 45 | +reaper.defer(function () end) |
0 commit comments