View Single Post
Old 10-26-2018, 01:01 PM   #77
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Julian, I followed your example in post #46 trying to mimick mouseclicks but it works the first time and fails all the other times. Any idea why?
This is the test code:


Code:
reaper.ShowConsoleMsg("This message should always be cleared\n")
local RSwindow = reaper.JS_Window_Find("ReaScript console output", true)
local _, leftX, topY, rightX, bottomY = reaper.JS_Window_GetRect(RSwindow)
-- "clear" button
local buttonX = rightX - 114
local buttonY = bottomY -27
-- Get button window
local buttonWindow = reaper.JS_Window_FromPoint(buttonX, buttonY)
_, 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)
P.S. If I close the Console window and run the script again, it works. But if I keep running the script with the console window being open, then it fails.
P.S.2. Ok, I found it.. For it to work, I must first focus the button window using
Code:
reaper.ShowConsoleMsg("This message should always be cleared\n")
local RSwindow = reaper.JS_Window_Find("ReaScript console output", true)
local _, leftX, topY, rightX, bottomY = reaper.JS_Window_GetRect(RSwindow)
-- Get "clear" button window
local buttonWindow = reaper.JS_Window_FromPoint(rightX - 114, bottomY -27)
-- Post click message
reaper.JS_Window_SetFocus( buttonWindow )
reaper.JS_WindowMessage_Send(buttonWindow, "WM_LBUTTONDOWN", 0x0001, 0, 10, 10)
reaper.JS_WindowMessage_Send(buttonWindow, "WM_LBUTTONUP", 0x0000, 0, 10,10)
before the WindowMessage Posts
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 10-26-2018 at 01:11 PM.
amagalma is offline   Reply With Quote