is there a reascript api that knows if i'm interacting with a certain window in reaper?…
- User
is there a reascript api that knows if i'm interacting with a certain window in reaper? (for example, the fx inserts window)
- Assistant
- User
if not reaper.APIExists("JS_Window_GetFocus") then reaper.ShowMessageBox("JS_ReaScriptAPI extension is required", "Error", 0) return end
function main() -- Retrieve the currently focused window local focus_window = reaper.JS_Window_GetFocus()
-- Check if the focused window title matches the FX Window title if focus_window then local window_title = reaper.JS_Window_GetTitle(focus_window) if window_title and string.find(window_title, "VSTi: ") then reaper.ShowConsoleMsg("FX Inserts window is focused \n", "Window Focus",0) else reaper.ShowConsoleMsg("FX Inserts window is not focused \n", "Window Focus", 0) end else reaper.ShowConsoleMsg("No window is focused \n", "Window Focus", 0) end reaper.defer(main) end
main()
in this script, if I'm not actively interacting with the window with the mouse, I want the focus to go to the main reaper window. how can i do that
- Assistant
- User
you misunderstood: I only want the focus to be on the vsti window if my mouse is currently interacting with that window
- Assistant
- User
not even hovering, just when clicking or when dragging the mouse
- Assistant
- User
if not reaper.APIExists("JS_Window_GetFocus") then reaper.ShowMessageBox("JS_ReaScriptAPI extension is required", "Error", 0) return end
function main() -- Retrieve the currently focused window local focus_window = reaper.JS_Window_GetFocus()
-- Check if the focused window title matches the FX Window title if focus_window then local window_title = reaper.JS_Window_GetTitle(focus_window) if window_title and string.find(window_title, "VSTi: ") then reaper.ShowConsoleMsg("FX Inserts window is focused \n", "Window Focus",0) reaper.JS_Window_SetFocus(main_hwnd) else reaper.ShowConsoleMsg("FX Inserts window is not focused \n", "Window Focus", 0) end else reaper.ShowConsoleMsg("No window is focused \n", "Window Focus", 0) end reaper.defer(main) end
main_hwnd = reaper.GetMainHwnd() main()
this not always focuses on the main window, sometimes the focus stays on the vsti window, why?
- Assistant