#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <StringConstants.au3>
#include <MsgBoxConstants.au3>
While 1
; Fenster definieren
$Form1_1 = GUICreate("Eti-Scan", 320, 227, 399, 282)
$Input1 = GUICtrlCreateInput("EAN / Artikelnummer", 80, 68, 217, 21)
$Input2 = GUICtrlCreateInput("Charge", 80, 110, 153, 21)
$Input3 = GUICtrlCreateInput("Menge", 80, 149, 97, 21)
$Label0 = GUICtrlCreateLabel("Scan für Etiketten 0.90", 80, 16, 223, 28)
GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("EAN", 8, 68, 40, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Charge", 8, 109, 62, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Menge", 8, 148, 58, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
; Eingabe auf 13 Stellen prüfen
	While 2
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Input1
			Sleep(500)
			$ean = GuiCtrlRead($Input1)
			If StringLen($ean)<>13 Then
				ControlSetText("Eti-Scan", "","[CLASS:Edit; INSTANCE:1]", "")
				ControlClick("Eti-Scan", "","[CLASS:Edit; INSTANCE:1]")
			Else
				ExitLoop
			EndIf
	EndSwitch
	WEnd
; Charge Eingabe 8 Zeichen
ControlClick ("Eti-Scan", "", "[CLASS:Edit; INSTANCE:2]")
ControlSetText("Eti-Scan", "","[CLASS:Edit; INSTANCE:2]", "")
	While 3
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Input2
			Sleep(500)
			$charge = GuiCtrlRead($Input2)
			; Erste Bedingung
			Local $aResult = StringRegExp($charge, '[0-9]{6,6}[a-zA-Z]{2}', $STR_REGEXPARRAYMATCH)
			If @error Then
				ControlSetText("Eti-Scan", "", "[CLASS:Edit; INSTANCE:2]", "")
				ControlClick("Eti-Scan", "", "[CLASS:Edit; INSTANCE:2]")
			; Zweite Bedingung
			;If StringLen($charge)<>8 Then
				;ControlSetText("Eti-Scan", "", "[CLASS:Edit; INSTANCE:2]", "")
				;ControlClick("Eti-Scan", "", "[CLASS:Edit; INSTANCE:2]")
			Else
				ExitLoop
			EndIf
	EndSwitch
	WEnd
; Mengeneingabe 1-100
	While 4
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Input3
			Sleep(500)
			$menge = GuiCtrlRead($Input3)
				If ($menge) > 101 Then
					ControlSetText("Eti-Scan", "","[CLASS:Edit; INSTANCE:3]", "")
					ControlClick("Eti-Scan", "","[CLASS:Edit; INSTANCE:3]")
				Else
					ExitLoop
				EndIf
	EndSwitch
	WEnd
MsgBox($MB_SYSTEMMODAL, "Schleife", "Schleife Ende")
GUIDelete("Eti-Scan")
WEnd
MsgBox($MB_SYSTEMMODAL, "Exit", "Exit")
Exit