Ich hatte mir für meinen Scanner mal ein Script geschrieben:
AutoIt
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
OnAutoItExitRegister('OnAutoItExit')
Global $sBuffer = ''
Global $hKeyProc = DllCallbackRegister('_KeyProc', 'long', 'int;wparam;lparam')
Global $hmod = _WinAPI_GetModuleHandle(0)
Global $hKeyHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hKeyProc), $hmod)
Global $hGui = GUICreate('Barcodescanner', 300, 100)
Global $idCode = GUICtrlCreateInput('', 10, 30, 280, 30, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_NUMBER))
GUICtrlSetFont(-1, 16, 400, 0, 'Courier New')
GUISetState()
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Exit
Func _EvaluateKey($keycode)
Switch $keycode
Case 48 To 57 ; 0 - 9
$sBuffer &= Chr($keycode)
Case 13 ; RETURN
ConsoleWrite(StringFormat('Barcode-Nummer = %i\r\n', $sBuffer))
GUICtrlSetData($idCode, $sBuffer)
$sBuffer = ''
Case 27 ; ESC
Exit
Case Else
$sBuffer = ''
EndSwitch
EndFunc ;==>_EvaluateKey
Func _KeyProc($nCode, $wParam, $lParam)
Local $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hKeyHook, $nCode, $wParam, $lParam)
If $wParam = $WM_KEYDOWN Then _EvaluateKey(DllStructGetData($tKEYHOOKS, 'vkCode'))
Return _WinAPI_CallNextHookEx($hKeyHook, $nCode, $wParam, $lParam)
EndFunc ;==>_KeyProc
Func OnAutoItExit()
_WinAPI_UnhookWindowsHookEx($hKeyHook)
DllCallbackFree($hKeyProc)
EndFunc ;==>OnAutoItExit
Alles anzeigen
Das hängt aber auch davon ab, wie Dein Scanner die Daten sendet (meist konfigurierbar). Meinen Scanner habe ich so eingestellt, dass er die Nummer und anschließend ein <RETURN> sendet.
Damit klappt das mit obigen Script, dass die Nummer automatisch ins Inputfeld eingetragen wird.