#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
Global $assot[19][2] = [ _
[1, '1 - 窗口客户区'], _
[2, '2 - 窗口标题栏'], _
[3, '3 - 窗口图标'], _
[5, '5 - 窗口菜单'], _
[6, '6 - 水平滚动条'], _
[7, '7 - 垂直滚动条'], _
[8, '8 - 窗口最小化按钮'], _
[9, '9 - 窗口最大化按钮'], _
[10, '10 - 窗口左边框'], _
[11, '11 - 窗口右边框'], _
[12, '12 - 窗口顶边框'], _
[13, '13 - 窗口左上角'], _
[14, '14 - 窗口右上角'], _
[15, '15 - 窗口底边框'], _
[16, '16 - 窗口左下角'], _
[17, '17 - 窗口右下角'], _
[18, '18 - 窗口框架'], _ ; 如果不改变窗口大小样式 (-1)
[20, '20 - 窗口关闭按钮'], _
[21, '21 - 窗口问号符']]
Global $k = 0, $Byfer
$hGui = GUICreate("WM_SETCURSOR", 510, 140, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_HSCROLL, $WS_VSCROLL), $WS_EX_TOPMOST)
GUICtrlCreateLabel('滑动窗口鼠标光标时发送 WM_SETCURSOR 消息.', 5, 3, 400, 17)
$Button = GUICtrlCreateButton('按钮', 10, 25, 70, 25)
$Button = GUICtrlCreateButton('按钮2', 90, 25, 70, 25)
$StatusBar = GUICtrlCreateLabel('123', 5, 55, 270, 74)
GUISetState()
GUIRegisterMsg($WM_SETCURSOR, "WM_SETCURSOR")
Do
Until GUIGetMsg() = -3
Func WM_SETCURSOR($hWnd, $Msg, $wParam, $lParam)
$k += 1
$Hittest = BitAND($lParam, 0xFFFF) ; _WinAPI_LoWord 低位字
$MouseMsg = BitShift($lParam, 16) ; _WinAPI_HiWord 高位字
WinSetTitle($hGui, '', '消息发生次数: ' & $k)
$info_ID = '?'
For $i = 0 To 18
If $Hittest = $assot[$i][0] Then
$info_ID = $assot[$i][1]
ExitLoop
EndIf
Next
$Tmp = $info_ID & @LF & '句柄 = ' & $wParam & @LF & '控件 ID = ' & _WinAPI_GetDlgCtrlID($wParam) & @CRLF & '鼠标消息 = ' & $MouseMsg
If $Tmp <> $Byfer Then
GUICtrlSetData($StatusBar, $Tmp)
$Byfer = $Tmp
EndIf
Return $GUI_RUNDEFMSG
EndFunc