Simulate Mouse Hover over Any UI element for any windows application

664 Views Asked by At

For context, my mission is to simulate all mouse interactions/inputs for a specific window handle without having the mouse actually be over said window.

I’ve gotten very far with SendMessageA() and sending over WM_LBUTTONDOWN/UP, and the R version of that for right click.

For example SendMessageA(m_TargetWindow, WM_RBUTTONUP, MK_RBUTTON, MAKELPARAM(x,y)); works great for sending a Right Button Up at location x,y of the window.

That said, first and foremost, if my mission is not possible for all mouse interactions, including simulating drag, and in this case hover (and it's end), then that would save me a lot of time.

If it is possible, then I'll continue to figure out the rest, but right now hover is being more tricky than the other send messages commands (Scroll is/was too, but I worked around it for now). Reading the docs does indicate some nuances, like TrackMouseEvent(), but I haven't made sense of it yet. I'm also not sure if Hover is the right way to think about it, as it might be a Mouse Enter/Leave type of deal.

This is what I've tried so far.

SendMessageA(m_TargetWindow, WM_MOUSEHOVER, MK_LBUTTON, MAKELPARAM(x,y));

and

TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_HOVER;
tme.hwndTrack = m_TargetWindow;
tme.dwHoverTime = HOVER_DEFAULT;

SendMessageA(m_TargetWindow, WM_MOUSEHOVER, MK_LBUTTON, MAKELPARAM(x,y));

The idea being that at location x,y of the window, it would simulate a hover event for the m_TargetWindow.

0

There are 0 best solutions below