Marc Hillman
2010-03-22 07:28:23 UTC
I'm trying to control a Delphi app by remote control from another app
(VB.NET), and I've hit a problem.
I can send keystrokes to the application, but I can only access some of the
program features - those that have a menu item.
I need to press a button on a toolbar, which presents me with two problems
a) how to locate the button, and b) how to simulate a mouse click on it.
I can locate the handle of the window that contains toolbar, and I know the
x-y position of the button in question within this window, but it is a
customisable toolbar, so the position, indeed presence, of the button is
unpredictable. How can I locate the location of a specific button within
this window? The window class of the toolbar is "tdpnpanel"
What messages do I need to send to simulate a mouseclick? I assumed a
WM_LBUTTONOWN followed by a WM_LBUTTONUP would be sufficient, but below is
the entire sequence of messages that occur when I click the button. Are all
these really necessary? Is there a simpler way to simulate a mouse click?
<00095> 000508B8 S WM_NCHITTEST xPos:190 yPos:96
<00096> 000508B8 R WM_NCHITTEST nHittest:HTCLIENT
<00097> 000508B8 S WM_MOUSEACTIVATE hwndTopLevel:00060830 nHittest:HTCLIENT
uMsg:WM_LBUTTONDOWN
<00098> 000508B8 R WM_MOUSEACTIVATE fuActivate:MA_ACTIVATE
<00099> 000508B8 S WM_SETCURSOR hwnd:000508B8 nHittest:HTCLIENT
wMouseMsg:WM_LBUTTONDOWN
<00100> 000508B8 R WM_SETCURSOR fHaltProcessing:False
<00101> 000508B8 P WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:190 yPos:12
<00102> 000508B8 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:190 yPos:12
<00103> 000508B8 S WM_NCHITTEST xPos:190 yPos:96
<00104> 000508B8 R WM_NCHITTEST nHittest:HTCLIENT
<00105> 000508B8 P WM_LBUTTONUP fwKeys:0000 xPos:190 yPos:12
<00106> 000508B8 S WM_CAPTURECHANGED hwndNewCapture:00000000
<00107> 000508B8 R WM_CAPTURECHANGED
<00108> 000508B8 P WM_PAINT hdc:00000000
<00109> 000508B8 S WM_PAINT hdc:00000000
<00110> 000508B8 R WM_PAINT
<00111> 000508B8 S WM_PAINT hdc:00000000
<00112> 000508B8 R WM_PAINT
(VB.NET), and I've hit a problem.
I can send keystrokes to the application, but I can only access some of the
program features - those that have a menu item.
I need to press a button on a toolbar, which presents me with two problems
a) how to locate the button, and b) how to simulate a mouse click on it.
I can locate the handle of the window that contains toolbar, and I know the
x-y position of the button in question within this window, but it is a
customisable toolbar, so the position, indeed presence, of the button is
unpredictable. How can I locate the location of a specific button within
this window? The window class of the toolbar is "tdpnpanel"
What messages do I need to send to simulate a mouseclick? I assumed a
WM_LBUTTONOWN followed by a WM_LBUTTONUP would be sufficient, but below is
the entire sequence of messages that occur when I click the button. Are all
these really necessary? Is there a simpler way to simulate a mouse click?
<00095> 000508B8 S WM_NCHITTEST xPos:190 yPos:96
<00096> 000508B8 R WM_NCHITTEST nHittest:HTCLIENT
<00097> 000508B8 S WM_MOUSEACTIVATE hwndTopLevel:00060830 nHittest:HTCLIENT
uMsg:WM_LBUTTONDOWN
<00098> 000508B8 R WM_MOUSEACTIVATE fuActivate:MA_ACTIVATE
<00099> 000508B8 S WM_SETCURSOR hwnd:000508B8 nHittest:HTCLIENT
wMouseMsg:WM_LBUTTONDOWN
<00100> 000508B8 R WM_SETCURSOR fHaltProcessing:False
<00101> 000508B8 P WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:190 yPos:12
<00102> 000508B8 P WM_MOUSEMOVE fwKeys:MK_LBUTTON xPos:190 yPos:12
<00103> 000508B8 S WM_NCHITTEST xPos:190 yPos:96
<00104> 000508B8 R WM_NCHITTEST nHittest:HTCLIENT
<00105> 000508B8 P WM_LBUTTONUP fwKeys:0000 xPos:190 yPos:12
<00106> 000508B8 S WM_CAPTURECHANGED hwndNewCapture:00000000
<00107> 000508B8 R WM_CAPTURECHANGED
<00108> 000508B8 P WM_PAINT hdc:00000000
<00109> 000508B8 S WM_PAINT hdc:00000000
<00110> 000508B8 R WM_PAINT
<00111> 000508B8 S WM_PAINT hdc:00000000
<00112> 000508B8 R WM_PAINT