[Closed] Automate Button Click: windowsPostMessage/uiAccessor
Hi all,
I’m working on an experiment of sorts and as part of this I need to manually press the button located on Corona’s VFB. I know there are other ways to initiate a render, quick max render, render(),etc but I think in this circumstance the button press on VFB may possibly bypass a strange issue I’m having. I’ve written a little test script to run on my machine.
I’ve tried using uiAccessor but it seems unable to interact with anything in Corona’s VFB, so I did some research on windows.sendMessage/postMessage but I don’t seem to have it quite right.
Here is my code:
try (destroyDialog CheckDialogTest) catch ()
--Global Variables
global hwnd
fn checkDialogs = (
hwnd = dialogMonitorOps.getWindowHandle()
dialogTitle = ""
dialogTitle = uiAccessor.getWindowText hwnd
print(dialogTitle)
if dialogTitle != undefined then (
if (matchPattern dialogTitle pattern:"Corona 1.7 (hotfix 3) |*" == true) then (
print(windows.getChildrenHWND HWND)
controls = windows.getChildrenHWND hwnd
renderBut = controls[11][1]
WM_LBUTTONDOWN = 0x0201
WM_LBUTTONUP = 0x0202
windows.postMessage renderBut WM_LBUTTONDOWN
windows.postmessage renderBut WM_LBUTTONUP
--uiAccessor.pressButtonByName "Render"
)
)
true
)
--Create test rollout
rollout CheckDialogTest "Check Dialog Test" width:200 height:95
(
button onButton "Dialog Monitor On" height:40
button offButton "Dialog Monitor Off" height: 40
on onButton pressed do (
--Add and start the dialog monitoring
dialogMonitorOps.interactive = false
dialogMonitorOps.unregisterNotification id:#test
dialogMonitorOps.registerNotification checkDialogs id:#test
dialogMonitorOps.enabled = true
)
on offButton pressed do (
dialogMonitorOps.enabled = false
dialogMonitorOps.unregisterNotification
)
on CheckDialogTest closed do (
dialogMonitorOps.enabled = false
dialogMonitorOps.unregisterNotification
)
)
createdialog CheckDialogTest
And here is the error message I get out of the listener:
-- Frame:
-- renderBut: 1843508P
-- WM_LBUTTONDOWN: 513
-- dialogTitle: "Corona 1.7 (hotfix 3) | 64×64px (1:1) | Camera: | Frame "
-- controls: #(#(6431086P, 3350898P, 3350898P, "wxWindowNR", "Ctrl+C", 0P, 3350898P, 3350898P) ...)
-- WM_LBUTTONUP: 514
RenderBut is the correct id? for the first element in the array that holds the “Render” button.
I appreciate any help, thanks!
Any help or insight in how to get this button press working via postMessage or sendMessage would be greatly appreciated.
#0 you can use UIAccessor.PressButton <HWND>hwnd
#1 use sendMessage but you have to specify the position of mouse press:
windows.sendmessage hwnd WM_LBUTTONDOWN 0[b] 0[/b]
windows.sendmessage hwnd WM_LBUTTONUP 0 [b]0[/b]
Thanks for the response Dennis. I think I would prefer to press the button via UIAccessor. I am still missing something.
I’ve added:
renderButtonGetChild = windows.getChildHWND HWND "Render"
UIAccessor.PressButton renderButtonGetChild
renderButtonGetChild does appear to return the correct button but it still does not actually press it.
Printing renderButtonGetChilds:
renderButtonGetChild: #(7346758P, 1312972P, 1312972P, "wxWindowNR", "Render", 0P, 1312972P, 1312972P)