Цитата HORRIBLE:
пример мониторинга нажатия клавиш на клавиатуре »
|
Начиная с версии 3.2.10.0 DllCallBack функции включены в AutoIt по умолчанию (так сказать стали нативными), соответсвенно нужно немного исправить скрипт:
Код:

Global Const $WH_KEYBOARD_LL = 13
Global $hHook, $pStub_KeyProc
Global $pStub_KeyProc = DllCallbackRegister("_KeyProc", "int", "int;ptr;ptr")
Global $hmod = DllCall("kernel32.dll","hwnd","GetModuleHandle","ptr",0)
Global $hHook = DllCall("user32.dll","hwnd","SetWindowsHookEx","int", _
$WH_KEYBOARD_LL,"ptr",DllCallbackGetPtr($pStub_KeyProc),"hwnd",$hmod[0],"dword",0)
Global $buffer = ""
MsgBox(4096,"","Type anything anywhere and it will appear in the top left corner of the screen.")
While 1
Sleep(10)
WEnd
Func EvaluateKey($keycode)
If (($keycode > 22) And ($keycode < 91)) _
Or (($keycode > 47) And ($keycode < 58)) Then
$buffer &= Chr($keycode)
ToolTip($buffer,0,0)
ElseIf ($keycode > 159) And ($keycode < 164) Then
Return
EndIf
EndFunc
Func _KeyProc($nCode, $wParam, $lParam)
Local $ret,$KEYHOOKSTRUCT
If $nCode < 0 Then
$ret = DllCall("user32.dll","long","CallNextHookEx","hwnd",$hHook[0], _
"int",$nCode,"ptr",$wParam,"ptr",$lParam)
Return $ret[0]
EndIf
If $wparam = 256 Then
$KEYHOOKSTRUCT = DllStructCreate("dword;dword;dword;dword;ptr",$lParam)
EvaluateKey(DllStructGetData($KEYHOOKSTRUCT,1))
EndIf
$ret = DllCall("user32.dll","long","CallNextHookEx","hwnd",$hHook[0], _
"int",$nCode,"ptr",$wParam,"ptr",$lParam)
Return $ret[0]
EndFunc
Func OnAutoItExit()
DllCall("user32.dll","int","UnhookWindowsHookEx","hwnd",$hHook[0])
EndFunc