0

我正在尝试创建一个空窗口,用于处理 WinProc 中的 WM_MOUSEMOVE 消息:

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;
    }

我希望我可以在 IE 中将超链接悬停,但结果是超链接在很短的时间内仅显示为悬停样式,然后转为正常,然后再次悬停,然后正常。在 www.amazon.com,当我模拟悬停链接(“今日特卖”)时,链接闪烁。

我想有一个更好的方法可以做到,即使IE窗口被其他一些窗口覆盖,它也可以使IE与mouseevent一起行动。等待最佳解决方案~orz

上面是当我真正悬停链接时的 spy++ 日志。并且模拟与真实消息相同

<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
<01309> 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
4

2 回答 2

1

这是因为 IE 调用 WindowFromPoint() 来获取前景窗口,如果结果不是你的 IE 窗口,它就知道你的鼠标不存在。一个可能的解决方案是挂钩 API。

于 2012-02-23T02:17:08.870 回答
0

你的代码没有问题。问题在于 Windows 发送消息的方式。

当您移动鼠标时,Windows 会向屏幕上的每个窗口发送消息。因此,每当您将WM_MOUSEMOVE消息发送到 IE 窗口句柄时,Windows 本身都会发送另一个消息,告诉您鼠标不存在。

所以这是一场小比赛...

于 2010-01-18T12:43:50.340 回答