da ist es:
AutoIt
#include <GUIConstantsEx.au3>
#include <StructureConstants.au3>
#include <WinAPIConstants.au3>
#include <WinAPIInternals.au3>
#include <WinAPISys.au3>
#include <WinAPISysInternals.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
#include <File.au3>
#include <WinAPI.au3>
Global $Gewerk = "Polsterei"
Global $Titel = "Polsterei.htm"
Global $Titelmin = "Polsterei_min.htm"
Global $Freigabe = "\\ste01\planung\"
Global $hmod, $hHook, $hStub_KeyProc, $buffer = '', $scannerbufferflag = 0
Global $LogText =""
Global $Eingabe
Global $File[5]
; Hier den Postfix-Code von eurem Scanner eintragen.
Global $g_iPostfix = 0x0D ;Enter
; Hier den Prefix-Code von eurem Scanner eintragen.
Global $g_iPrefix = 0x71 ;F2
HotKeySet('{ESC}', '_Exit')
OnAutoItExitRegister('OnAutoItExit')
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, 140)
Global $idBarcode = GUICtrlCreateLabel('', 10, 10, 280, 30)
GUICtrlSetFont(-1, 16, 400, 0, 'Courier New')
Global $idInput = GUICtrlCreateInput('', 10, 50, 280, 30)
GUICtrlSetFont(-1, 16, 400, 0, 'Courier New')
GUISetState(@SW_HIDE)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
consolewrite("ende")
Exit
Func _Exit()
Exit
EndFunc
; ACHTUNG! Callback-Funktion!
; In dieser Funktion darf es keinen blockierenden Code (z.B. MsgBox, Sleep, etc.) geben!
; Hier werden direkt die virtuellen Keycodes der Tastatur ausgewertet:
; https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
Func _KeyProc($nCode, $wParam, $lParam)
Local $tKBDLLHOOK = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
Local $iKeyCode = $tKBDLLHOOK.vkCode, $iPressTime
Local Static $sBuffer = '', $bBarcodeActive = False
If $nCode >= 0 Then
If $iKeyCode = $g_iPrefix And $wParam = $WM_KEYUP Then
$bBarcodeActive = Not $bBarcodeActive
ConsoleWrite('$bBarcodeActive = ' & $bBarcodeActive & @CRLF)
$sBuffer = ''
EndIf
If $bBarcodeActive Then
Switch $wParam
Case $WM_KEYDOWN
Return 1
Case $WM_KEYUP
Switch $iKeyCode ; Keycode auswerten
Case $g_iPostfix
ConsoleWrite(StringFormat('Barcode = "%s"\r\n', $sBuffer))
_StatusSave($sBuffer)
$sBuffer = ''
$bBarcodeActive = False
ConsoleWrite('$bBarcodeActive = ' & $bBarcodeActive & @CRLF)
Return 1
Case 0x30 To 0x39, 0x41 To 0x5A ; 0 - 9, A - Z
$sBuffer &= Chr($iKeyCode)
Return 1
EndSwitch
EndSwitch
EndIf
EndIf
Return _WinAPI_CallNextHookEx($hKeyHook, $nCode, $wParam, $lParam)
EndFunc ;==>_KeyProc
; Wichtig! Beim Programmende den Hook wieder entfernen.
Func OnAutoItExit()
_WinAPI_UnhookWindowsHookEx($hKeyHook)
DllCallbackFree($hKeyProc)
EndFunc ;==>OnAutoItExit
Func _StatusSave($sBuffer)
Local $hFile
If FileExists($Freigabe & "\Prod-Status\" & $Gewerk & "\" & $sBuffer & "_Start.log") Then
$hFile = FileOpen($Freigabe & "\Prod-Status\" & $Gewerk & "\" & $sBuffer & "_Ende.log", 1)
beep(500,200)
beep(500,200)
Else
$hFile = FileOpen($Freigabe & "\Prod-Status\" & $Gewerk & "\" & $sBuffer & "_Start.log", 1)
beep(500,200)
EndIf
_FileWriteLog($hFile, $sBuffer & @CRLF)
FileClose($hFile)
EndFunc ;==>StatusSave
Alles anzeigen