#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
OnAutoItExitRegister("Cleanup")
$hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam")
$hmod = _WinAPI_GetModuleHandle(0)
$hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hStub_KeyProc), $hmod)
While 1
Sleep(1000)
WEnd
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 = $WM_KEYDOWN Then
If DllStructGetData($tKEYHOOKS, "vkCode") = 0x5B Then
ConsoleWrite("DOWN ")
Return -1
EndIf
EndIf
Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam)
EndFunc ;==>_KeyProc
Func Cleanup()
_WinAPI_UnhookWindowsHookEx($hHook)
DllCallbackFree($hStub_KeyProc)
EndFunc ;==>Cleanup