4ggr35510n Posted November 16, 2010 Share Posted November 16, 2010 (edited) Greetings! I have some serious issues with registering MouseProc with SetWindowsHookEx function... As long as mouse stays inside the GUI - console returns messages etc. - properly! But as soon as mouse leaves GUI window - everything stops, no more messages... Here's the code: expandcollapse popupOnAutoItExitRegister('OnAutoItExit') $hKey_Proc = DllCallbackRegister("MouseProc", "int", "int;ptr;ptr") $hM_Module = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0) $hM_Hook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", 7, "ptr", DllCallbackGetPtr($hKey_Proc), "hwnd", $hM_Module[0], "dword", 0) ; unlogical! GUICreate('Test') GUISetState() Do Until GuiGetMsg() = -3 Exit Func MouseProc($nCode, $wParam, $lParam) ConsoleWrite($nCode ) Switch $wParam Case 0x0201 ConsoleWrite(@CRLF & 'LEFT DOWN' & @CRLF) Case 0x0202 ConsoleWrite(@CRLF & 'LEFT UP' & @CRLF) Case 0x0206 ConsoleWrite(@CRLF & 'RIGHT DOUBLE DOWN' & @CRLF) Case 0x020A ConsoleWrite(@CRLF & 'WHEEL' & @CRLF) EndSwitch EndFunc Func OnAutoItExit() DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hM_Hook[0]) $hM_Hook[0] = 0 DllCallbackFree($hKey_Proc) $hKey_Proc = 0 EndFunc ;==>OnAutoItExitWhat's wrong? How should it look like to work properly? Basically, I'd like to create non-Low Level MouseHook for receiving mouse msg just from one window. Non-Low Levelr = CPU saving purpose. (same code with $WH_LL_MOUSE insetad of $WH_MOUSE [int 7 stands for it] works perfectly... why? )BR, I hope for your help :]4gr Edited November 16, 2010 by 4ggr35510n Link to comment Share on other sites More sharing options...
YellowLab Posted December 23, 2010 Share Posted December 23, 2010 You may want to look at the following: You can't see a rainbow without first experiencing the rain. Link to comment Share on other sites More sharing options...
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