How to simulate mousemove event from one window to another?
I am trying to Create an empty window, which process the WM_MOUSEMOVE message in WinProc:
case WM_MOUSEMOVE:
{
HWND otherHwnd = HWND(0x000608FC);
POINT pt = {LOWORD(lParam), HIWORD(lParam)};
ClientToScreen(otherHwnd, &pt);
PostMessage(otherHwnd, WM_TIMER, WPARAM(4096), 0);
PostMessage(otherHwnd, message, wParam, lParam);
SendMessage(otherHwnd, WM_NCHITTEST, NULL, (LPARAM)MAKELONG(pt.x, pt.y));
SendMessage(otherHwnd, WM_NCHITTEST, NULL, (LPARAM)MAKELONG(pt.x, pt.y));
SendMessage(otherHwnd, WM_NCHITTEST, NULL, (LPARAM)MAKELONG(pt.x, pt.y));
SendMessage(otherHwnd, WM_SETCURSOR, WPARAM(otherHwnd), (LPARAM)MAKELONG(HTCLIENT, WM_MOUSEMOVE));
break;
}
I hope I can hover the hyberlink in IE, but result is the hyberlink only be showed as hover style in a very short time, then it turn to normal, and then again hover, then normal. At www.amazon.com, when I simulate to hover the link("Today's Deals ") , the link is blinking.
I think there is a better way to do it, even the IE window is covered with some other windows, it can make the IE act with the mouseevent. waiting for the best solution~ orz
Above is the spy++ logs when I realy hover the link. and the simulate is as same as the real message
<01277> 000608FC S WM_SETCURSOR hwnd:000608FC nHittest:HTCLIENT wMouseMsg:WM_MOUSEMOVE
<01278> 000608FC R WM_SETCURSOR fHaltProcessing:False
<01279> 000608FC P WM_MOUSEMOVE fwKeys:0000 xPos:406 yPos:50
<01280> 000608FC P WM_TIMER wTimerID:4096 tmprc:00000000
<01281> 000608FC S WM_NCHITTEST xPos:520 yPos:283
<01282> 000608FC R WM_NCHITTEST nHittest:HTCLIENT
<01283> 000608FC S WM_NCHITTEST xPos:520 yPos:283
<01284> 000608FC R WM_NCHITTEST nHittest:HTCLIENT
<01285> 000608FC S WM_NCHITTEST xPos:520 yPos:283
<01286> 000608FC R WM_NCHITTEST nHittest:HTCLIENT
<01287> 000608FC S WM_NCHITTEST xPos:520 yPos:283
<01288> 000608FC R WM_NCHITTEST nHittest:HTCLIENT
<01289> 000608FC S WM_SETCURSOR hwnd:000608FC nHittest:HTCLIENT wMouseMsg:WM_MOUSEMOVE
<01290> 000608FC R WM_SETCURSOR fHaltProcessing:False
<01291> 000608FC P WM_MOUSEMOVE fwKeys:0000 xPos:406 yPos:50
<01292> 000608FC P WM_TIMER wTimerID:4096 tmprc:00000000
<01293> 000608FC S WM_NCHITTEST xPos:520 yPos:283
<01294> 000608FC R WM_NCHITTEST nHittest:HTCLIENT
<01295> 000608FC S WM_NCHITTEST xPos:520 yPos:283
<01296> 000608FC R WM_NCHITTEST nHittest:HTCLIENT
<01297> 000608FC S WM_NCHITTEST xPos:520 yPos:283
<01298> 000608FC R WM_NCHITTEST nHittest:HTCLIENT
<01299> 000608FC S WM_NCHITTEST xPos:520 yPos:283
<01300> 000608FC R WM_NCHITTEST nHittest:HTCLIENT
<01301> 000608FC S WM_SETCURSOR hwnd:000608FC nHittest:HTCLIENT wMouseMsg:WM_MOUSEMOVE
<01302> 000608FC R WM_SETCURSOR fHaltProcessing:False
<01303> 000608FC P WM_MOUSEMOVE fwKeys:0000 xPos:406 yPos:50
<01304> 000608FC S WM_NCHITTEST xPos:520 yPos:283
<01305> 000608FC R WM_NCHITTEST nHittest:HTCLIENT
<01306> 000608FC P WM_TIMER wTimerID:4096 tmprc:00000000
<01307> 000608FC S WM_NCHITTEST xPos:520 yPos:283
<01308> 000608FC R WM_NCHITTEST nHittest:HTCLIENT
<013开发者_运维知识库09> 000608FC S WM_NCHITTEST xPos:520 yPos:283
<01310> 000608FC R WM_NCHITTEST nHittest:HTCLIENT
<01311> 000608FC S WM_NCHITTEST xPos:521 yPos:281
<01312> 000608FC R WM_NCHITTEST nHittest:HTCLIENT
This is because IE calls WindowFromPoint() to obtain the foreground window, if the result is not your IE window, it knows your mouse isn't there. A possible solution is to hook the API.
There's nothing wrong with your code. The problem is with the way Windows send messages.
As you move your mouse, Windows dispatches messages to every and all windows on screen. So whenever you send the WM_MOUSEMOVE
message to the IE windows handle, Windows itself send another telling that the mouse isn't there.
So it's a little race...
精彩评论