I was wondering, is there some API call, or MFC member function, that would let me simulate a left/right mouse click ANYWHERE on the screen?
I know about ::SendMessage (HWND_BROADCAST, yaddi yoddi ya... but that doesn't seem to work, because the message isn't sent to child windows, and the coordinates are relative to my program's main window, which is a dialog box.
Here is the code I am currently using to try to get this to work:
WORD lo, hi;
ScreenToClient (AfxGetApp ()->m_pMainWnd->m_hWnd, &command.m_Point);
lo = (WORD) command.m_Point.x;
hi = (WORD) command.m_Point.y;
temp = (LPARAM) (((LPARAM) (lo)) | ((LPARAM) (hi << 16)));
::SendMessage (HWND_BROADCAST, WM_LBUTTONDOWN, MK_LBUTTON, temp);
The command.m_Point is a POINT stucture containing the screen coordinates where I want the mouse click to be simulated. I have tried the code with and without the ScreenToClient function, no effect. I also made sure that the casting was being done correctly as you can see. I imagine I can take out a lot of it, but I was just experimenting. I have also tried, instead of HWND_BROADCAST, AfxGetApp ()->m_pMainWnd, still no effect.
Anyone have any insight as to how to accomplish this?
Help Me A Lot! :-)