E1M1 Posted November 18, 2010 Share Posted November 18, 2010 Example from help, doesnt seem to work with $WH_GETMESSAGE. With following code only $WH_KEYBOARD_LL and $WH_MOUSE_LL works but cant get get any other $idHook params working. Any ideas about how to use $WH_GETMESSAGE? and is there also way to dedect what window receives given message? expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <WinAPI.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> ;~ Opt('MustDeclareVars', 1) Global $hHook, $hStub_KeyProc, $buffer = "" _Main() Func _Main() OnAutoItExitRegister("Cleanup") Local $hmod $hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam") $hmod = _WinAPI_GetModuleHandle(0) $hHook = _WinAPI_SetWindowsHookEx($WH_GETMESSAGE, DllCallbackGetPtr($hStub_KeyProc), $hmod) Run("Notepad") WinWait("Untitled -") WinActivate("Untitled -") While 1 Sleep(10) WEnd EndFunc ;==>_Main ;=========================================================== ; callback function ;=========================================================== Func _KeyProc($nCode, $wParam, $lParam) Local $tKEYHOOKS $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndIf If $wParam <> "" Then ConsoleWrite($wParam & @CRLF) EndIf Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc ;==>_KeyProc Func Cleanup() _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hStub_KeyProc) EndFunc ;==>Cleanup edited 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