#Include <WinAPI.au3>
#include <WindowsConstants.au3>
OnAutoItExitRegister("OnAutoItExit")
$_whand = DllCallbackRegister("_Mouse_Events_Handler", "int", "int;ptr;ptr")
$_whmod = _WinAPI_GetModuleHandle(0)
$_whook=_WinAPI_SetWindowsHookEx($WH_MOUSE_LL,DllCallbackGetPtr($_whand),$_whmod)
While 1
Sleep(1)
WEnd
Func _Mouse_Events_Handler($wnCode, $wwParam, $wlParam)
If $wnCode < 0 Then
Return _WinAPI_CallNextHookEx($_whook, $wnCode, $wwParam, $wlParam) ;消息传递到下一个钩子
EndIf
Switch $wwParam
Case $WM_LBUTTONUP ;按下鼠标左键
Return 1
Case $WM_RBUTTONDOWN ;按下鼠标右键
Return 1
Case $WM_MBUTTONDOWN ;按下鼠标中键
Return 1
Case $WM_MOUSEWHEEL ;鼠标轮转动
Return 1
EndSwitch
EndFunc
Func OnAutoItExit() ;退出时卸载钩子
_WinAPI_UnhookWindowsHookEx($_whook)
DllCallbackFree($_whand)
EndFunc ;==>OnAutoItExit
|