Sending a mouse message to the desktop?
I want my program to send mouse clicks to whatever the mouse is currently pointing to. I thought this could be accomplished by sending the appropriate mouse message to the desktop window, so I came up with this:
HWND lpDesktopWindow = ::GetDesktopWindow();
::SendMessage(lpDesktopWindow, WM_LBUTTONDOWN, 0, 0);
Unfortunately this doesn't seem to have any effect. Is it not working because I am passing 0 in place of the mouse coordinates? If this is the reason, how can I get the mouse coordinates? I can't monitor WM_MOUSEMOVE because the mouse isn't moving over my application. If the desktop gets the message with the proper coordinates will it then send the message to the application that the mouse is pointing to?