没事看到这两个事件,原来还要wm_mousemove事件的
#include <Winapi.au3>
Global Const $WM_MOUSEMOVE = 0x0200 ;鼠标移动
Global Const $WM_MOUSEHOVER = 0x02A1 ;鼠标停留
Global Const $WM_MOUSELEAVE = 0x02A3 ;鼠标离开
Global Const $TME_HOVER = 0x00000001
Global Const $TME_LEAVE = 0x00000002
$Form1 = GUICreate("测试", 261, 254, 192, 124)
GUISetState()
GUIRegisterMsg($WM_MOUSEMOVE, "WM_MOUSEMOVE")
GUIRegisterMsg($WM_MOUSEHOVER, "WM_MOUSEHOVER")
GUIRegisterMsg($WM_MOUSELEAVE, "WM_MOUSELEAVE")
While GUIGetMsg() <> -3
WEnd
Func WM_MOUSEMOVE($hWnd, $Msg, $wParam, $lParam)
$tagTRACKMOUSEEVENT = DllStructCreate("DWORD cbSize;DWORD dwFlags;HWND hwndTrack;DWORD dwHoverTime")
DllStructSetData($tagTRACKMOUSEEVENT, "cbSize", DllStructGetSize($tagTRACKMOUSEEVENT)) ;结构体缓冲区大小
DllStructSetData($tagTRACKMOUSEEVENT, "dwFlags", BitOR($TME_HOVER,$TME_LEAVE)) ;注册WM_MOUSEHOVER和$WM_MOUSELEAVE消息
DllStructSetData($tagTRACKMOUSEEVENT, "hwndTrack", $hWnd) ;当前窗口句柄
DllStructSetData($tagTRACKMOUSEEVENT, "dwHoverTime", 300) ;触发的时间300ms
$TRACKMOUSEEVENT = DllStructGetPtr($tagTRACKMOUSEEVENT)
DllCall("user32.dll", "bool", "TrackMouseEvent","ptr",$TRACKMOUSEEVENT)
EndFunc ;==>WM_MOUSEMOVE
Func WM_MOUSEHOVER($hWnd, $Msg, $wParam, $lParam)
$X = _WinAPI_LoWord($lParam)
$Y = _WinAPI_HiWord($lParam)
TrayTip("鼠标在窗口坐标", "X:" & $X & " Y:" & $Y, 1, 1)
EndFunc ;==>WM_MOUSEHOVER
Func WM_MOUSELEAVE($hWnd, $Msg, $wParam, $lParam)
TrayTip("提示","鼠标移出窗口了!",1,1)
EndFunc
|