dexto Posted May 23, 2009 Share Posted May 23, 2009 In Code for Keyboard Hook: #include <WinAPI.au3> #include <WindowsConstants.au3> Global $hHook Global $hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam") Global $hmod = _WinAPI_GetModuleHandle(0) Global $hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hStub_KeyProc), $hmod) Global $buffer = "" Func EvaluateKey($keycode) ConsoleWrite($keycode) EndFunc ;==>EvaluateKey ;=========================================================== ; 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 = 256 Then;256=keydown, 257=keyup EvaluateKey(DllStructGetData($tKEYHOOKS, "vkCode")) EndIf Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc ;==>_KeyProc Func OnAutoItExit() _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hStub_KeyProc) EndFunc ;==>OnAutoItExit What is the function of: Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) If it returns False of 0 will that disable the keyboard? Link to comment Share on other sites More sharing options...
Authenticity Posted May 23, 2009 Share Posted May 23, 2009 If you'll return anything non-zero then it'll prevent the system from passing it to the rest of the chain. If another application is registering it's own procedure latter, then the system is going to call it first. Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 23, 2009 Share Posted May 23, 2009 (edited) In Code for Keyboard Hook: #include <WinAPI.au3> #include <WindowsConstants.au3> Global $hHook <...redacted...> What is the function of: Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) If it returns False of 0 will that disable the keyboard? It's required by the Windows API specs, but I don't see (and wouldn't expect) details on the consequences for mis-handling it: MSDN: LowLevelKeyboardProc Function Parameters nCode [in] Specifies a code the hook procedure uses to determine how to process the message. If nCode is less than zero, the hook procedure must pass the message to the CallNextHookEx function without further processing and should return the value returned by CallNextHookEx. P.S. Your code doesn't run because there is no loop to keep it alive while waiting for events. Edited May 23, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
dexto Posted May 23, 2009 Author Share Posted May 23, 2009 Thanks guys. P.S. i use this as include (loop is in the main script) 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