MDCT Posted December 17, 2018 Posted December 17, 2018 Hello again, guys. I am having problem with MouseHook in 64bit app. If 64bit app window is active, the mouse hook is not returning result. I have read that we need to do 64bit mousehook so the hook still works on 64bit apps. https://stackoverflow.com/questions/15542783/global-keyhook-on-64-bit-windows Here, the OP found a solution, but it seems the OP was not sure if his or her solution is correct or not. Any help would be appreciated. Thanks guys. Here I give example of mouse hook that works only for 32bit, compile it to 64bit is not showing result on 64bit: expandcollapse popup; ~~ Mouse Hook ~~ ;For more info, Visit: http://msdn.microsoft.com/en-us/library/ms644986(VS.85).aspx ;Include GUI Consts #include <GUIConstants.au3> ;for $GUI_EVENT_CLOSE #Include <WinAPI.au3> ;for HIWORD HotKeySet("{ESC}", "OnAutoItExit") ;Consts/structs from msdn Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" ;~ Global Const $WH_MOUSE_LL = 14 ;already declared ;~ Global Const $tagPOINT = "int X;int Y" ;already declared ;Register callback $hKey_Proc = DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr") $hM_Module = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0) $hM_Hook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", $WH_MOUSE_LL, "ptr", DllCallbackGetPtr($hKey_Proc), "hwnd", $hM_Module[0], "dword", 0) Global $X,$Y While 1 Sleep(64) ConsoleWrite($X &" - "&$Y &@CRLF) WEnd Func _Mouse_Proc($nCode, $wParam, $lParam) ;function called for mouse events.. ;define local vars Local $info If $nCode < 0 Then ;recommended, see http://msdn.microsoft.com/en-us/library/ms644986(VS.85).aspx $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) ;recommended Return $ret[0] EndIf $info = DllStructCreate($MSLLHOOKSTRUCT, $lParam) ;used to get all data in the struct ($lParam is the ptr) $X = DllStructGetData($info, 1) $Y = DllStructGetData($info, 2) ;This is recommended instead of Return 0 $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $ret[0] EndFunc ;==>_Mouse_Proc Func OnAutoItExit() DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hM_Hook[0]) $hM_Hook[0] = 0 DllCallbackFree($hKey_Proc) $hKey_Proc = 0 Exit EndFunc ;==>OnAutoItExit
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now