View Single Post
Old 10-15-2018, 02:02 PM   #46
Human being with feelings
Join Date: Jul 2009
Posts: 2,752

Originally Posted by NextLevel View Post
Was wondering if you could post an example?
My goal is to be able to send a mouse click to a vst parameter(it's a button that can't normally be automated), however the vst's gui may be located in a different place each time the script is ran.
To do this, you don't need to move the mouse: instead, post a "WM_LBUTTONDOWN" message with the button coordinates to the window to simulate a mouse click, and then a "WM_LBUTTONUP" to lift the mouse button again.

AFAIK, you must send the message to the child window that contains the button, not the top-level VST window. To get this window -- as long as the VST window is not hidden behind other windows -- user JS_Window_FromPoint, using the coordinates of the button.

So, if you know the relative position of the button to the VST window, you can do the following:
(I didn't include any checks, such as checking that the VSTWindow is actually found.)
-- First, get VST position on screen
VSTWindow = reaper.JS_Window_Find("title of VST", true)
rOK, leftX, topY, rightX, bottomY = reaper.JS_Window_GetRect(VSTWindow)

-- Calculate button screen coordinates
buttonX = leftX + somethingX
buttonY = leftY + somethingY

-- Get button window
buttonWindow = reaper.JS_Window_FromPoint(buttonX, buttonY)
rOK, leftX, topY, rightX, bottomY = reaper.JS_Window_GetRect(buttonWindow)

-- Post click message
reaper.JS_WindowMessage_Post(buttonWindow, "WM_LBUTTONDOWN", 0x0001, 0, buttonX-leftX, buttonY-topY)
reaper.JS_WindowMessage_Post(buttonWindow, "WM_LBUTTONUP", 0x0000, 0, buttonX-leftX, buttonY-topY)
juliansader is online now   Reply With Quote