Cannot programmically press button, getting a WM_MOUSELEAVE after WM_LBUTTONDOWN
Posted on 2016-08-21
I am trying to press a graphical button that does not have a HWND. I have the following code:
Dim MousePos As Long = MakeDWord(clientPoint.X, clientPoint.Y)
Dim iDownResult As Long = SendMessage(wndHandle, WM_LBUTTONDOWN, MK_LBUTTON, MousePos)
Dim iUpResult As Long = SendMessage(wndHandle, WM_LBUTTONUP, MK_LBUTTON, MousePos)
However the button is not actually being pressed. The button graphic changes to the "pressed down" graphic, but the expected action from the button being pressed does not occur. Checking the window with SPY++ running shows that the messages are being received with correct arguments, however a "WM_MOUSELEAVE" is occurring after both SendMessages. The windows are active, have focus, and are on top of the screen.
When I test it by pressing the button manually there is no "WM_MOUSELEAVE".
How can I get past this and have the button actually press.