用第2种方法丝毫不会感觉到鼠标移动反应有迟钝,有没有hook.dll的相关资料?用hook.dll能中断鼠标消息的传递吗?
我把应用hook.dll的源码贴出来,请指教:
Const $WH_KEYBOARD = 2
Const $WH_CBT = 5
Const $WH_MOUSE = 7
Const $WM_AUTOITLBUTTONDOWN = 0x1400 + 0x0A30
Const $WM_AUTOITRBUTTONDOWN = 0x1400 + 0x0A31
Const $WM_AUTOITMBUTTONDOWN = 0x1400 + 0x0A32
Const $WM_AUTOITXBUTTONDOWN1 = 0x1400 + 0x0A33
Const $WM_AUTOITXBUTTONDOWN2 = 0x1400 + 0x0A34
Const $WM_AUTOITLBUTTONUP = 0x1400 + 0x0B30
Const $WM_AUTOITRBUTTONUP = 0x1400 + 0x0B31
Const $WM_AUTOITMBUTTONUP = 0x1400 + 0x0B32
Const $WM_AUTOITXBUTTONUP1 = 0x1400 + 0x0B33
Const $WM_AUTOITXBUTTONUP2 = 0x1400 + 0x0B34
Const $WM_AUTOITLDBLCLK = 0x1400 + 0x0C30
Const $WM_AUTOITRDBLCLK = 0x1400 + 0x0C31
Const $WM_AUTOITMDBLCLK = 0x1400 + 0x0C32
Const $WM_AUTOITXDBLCLK1 = 0x1400 + 0x0C33
Const $WM_AUTOITXDBLCLK2 = 0x1400 + 0x0C34
Const $WM_AUTOITMOUSEWHEELUP = 0x1400 + 0x0D30
Const $WM_AUTOITMOUSEWHEELDOWN = 0x1400 + 0x0D31
Const $WM_AUTOITMOUSEMOVE = 0x1400 + 0x0F30
Const $HCBT_SETFOCUS = 0x1400 + 0x1A30
Const $HCBT_ACTIVATE = 0x1400 + 0x1A31
Const $HCBT_CREATEWND = 0x1400 + 0x1A32
Const $HCBT_DESTROYWND = 0x1400 + 0x1A33
Const $HCBT_MINMAX = 0x1400 + 0x1A34
Const $WM_KEYDOWN = 0x0400 + 0x0A30
Const $WM_KEYUP = 0x0400 + 0x0A31
Global $n,$msg,$buffer = ""
Global $mouseldown=0
HotKeySet("{ESC}","GoAway")
TrayTip("","ESC键退出!!",8)
$gui = GUICreate("test")
Global $DLLinst = DLLCall("kernel32.dll","hwnd","LoadLibrary","str",".\hook.dll")
Global $mouseHOOKproc = DLLCall("kernel32.dll","hwnd","GetProcAddress","hwnd",$DLLInst[0],"str","MouseProc")
Global $hhMouse = DLLCall("user32.dll","hwnd","SetWindowsHookEx","int",$WH_MOUSE, _
"hwnd",$mouseHOOKproc[0],"hwnd",$DLLinst[0],"int",0)
DLLCall(".\hook.dll","int","SetValuesMouse","hwnd",$gui,"hwnd",$hhMouse[0])
GUIRegisterMsg($WM_AUTOITLDBLCLK,"myfunc")
GUIRegisterMsg($WM_AUTOITLBUTTONDOWN,"ldown")
GUIRegisterMsg($WM_AUTOITLBUTTONUP,"lup")
GUIRegisterMsg($WM_AUTOITRBUTTONDOWN,"rdown")
GUIRegisterMsg($WM_AUTOITRBUTTONUP,"rup")
While 1
$msg = GUIGetMsg()
If $msg = -3 Then ExitLoop
WEnd
Func MyFunc($hWndGUI, $MsgID, $WParam, $LParam)
TrayTip("","您刚才双击了鼠标左键.",5)
EndFunc
Func GoAway()
Exit
EndFunc
Func OnAutoItExit()
DLLCall("user32.dll","int","UnhookWindowsHookEx","hwnd",$hhMouse[0])
DLLCall("kernel32.dll","int","FreeLibrary","hwnd",$DLLinst[0])
EndFunc
Func ldown()
ToolTip("左键按下")
EndFunc
Func lup()
ToolTip("左键弹起")
EndFunc
Func rdown()
ToolTip("右键按下")
EndFunc
Func rup()
ToolTip("右键弹起")
EndFunc
|