The lowlevel-hook is not a good choice. Here is an example for WH_KEYBOARDHOOK. Click start, while the GUI is active type some keys, then stop, then choose an edit-area as target and press F9
#include<WinAPI.au3>
#include<WinAPIEx.au3>
Global $sStoredData = "", $fRecord = False
HotKeySet("{F9}", "_Resend")
$myGUI = GUICreate("")
$btn = GUICtrlCreateButton("Start", 10, 10)
GUISetState()
Global Const $ghcbKeyboardProc = DllCallbackRegister("_KeyboardProc", "lresult", "int;wparam;lparam")
Global Const $ghKeybordHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD, DllCallbackGetPtr($ghcbKeyboardProc), 0, _WinAPI_GetCurrentThreadId())
OnAutoItExitRegister("_gc")
While 1
Switch GUIGetMsg()
Case -3
Exit
Case $btn
$fRecord = Not $fRecord
GUICtrlSetData($btn, "Start")
If $fRecord Then GUICtrlSetData($btn, "Stop")
EndSwitch
WEnd
Func _Resend()
If WinActive($myGUI) Then Return
$s = $sStoredData
$sStoredData = ""
ConsoleWrite($s & @LF)
For $s In StringSplit($s, "|", 2)
If $s = "" Then ContinueLoop
$a = StringSplit($s, ";", 2)
$iFlags = 0
If $a[1] = "true" Then $iFlags = BitOR($iFlags, $KEYEVENTF_EXTENDEDKEY)
If $a[2] = "true" Then $iFlags = BitOR($iFlags, $KEYEVENTF_KEYUP)
_WinAPI_Keybd_Event(Number($a[0]), $iFlags)
Next
EndFunc
Func _gc()
_WinAPI_UnhookWindowsHookEx($ghcbKeyboardProc)
EndFunc
Func _KeyboardProc($nCode, $wParam, $lParam)
If $nCode < 0 Or Not $fRecord Then Return _WinAPI_CallNextHookEx($ghKeybordHook, $nCode, $wParam, $lParam)
Local $nVKeyCode = Number($wParam)
Local $fExtendedKey = BitAND($lParam, 2^24) <> 0
Local $fKeyUp = BitAND($lParam, 2^31) <> 0
$sStoredData &= $nVKeyCode & ";" & $fExtendedKey & ";" & $fKeyUp & "|"
Return 0xDEAD ; kill the key event
Return _WinAPI_CallNextHookEx($ghKeybordHook, $nCode, $wParam, $lParam)
EndFunc
PS: This should cover all keyboard input, even Winkey, Ctrl etc. As a result, keycombinations like Ctrl-C, Ctrl-V can be sent, too.