#Include <WinAPI.au3>
#include <WindowsConstants.au3>
While 1
Global $_endmouse=""
$_whand = DllCallbackRegister("_Mouse_Events_Handler", "int", "int;ptr;ptr")
$_whmod = _WinAPI_GetModuleHandle(0)
$_whook=_WinAPI_SetWindowsHookEx($WH_MOUSE_LL,DllCallbackGetPtr($_whand),$_whmod)
$mouse = _waitmouse()
Switch $mouse
Case 1
MsgBox(64,"","按下鼠标左键")
Case 2
MsgBox(64,"","按下鼠标右键")
Case 3
MsgBox(64,"","按下鼠标中键")
Case 4
MsgBox(64,"","鼠标轮转动")
EndSwitch
WEnd
Func _waitmouse()
While 1
Sleep(1)
If Not $_endmouse="" Then
_WinAPI_UnhookWindowsHookEx($_whook)
DllCallbackFree($_whand)
Return $_endmouse
EndIf
WEnd
EndFunc
Func _Mouse_Events_Handler($wnCode, $wwParam, $wlParam)
Switch $wwParam
Case $WM_LBUTTONUP ;按下鼠标左键
$_endmouse = 1
Case $WM_RBUTTONDOWN ;按下鼠标右键
$_endmouse = 2
Case $WM_MBUTTONDOWN ;按下鼠标中键
$_endmouse = 3
Case $WM_MOUSEWHEEL ;鼠标轮转动
$_endmouse = 4
EndSwitch
EndFunc
|