Je vous jette rapidement ici mon dernier script, presque optimisé : il s'agit d'un outil de relevé de n° de série à l'aide d'une douchette.
► Afficher le texte
Code : Tout sélectionner
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <Array.au3>
$dll = DllOpen("user32.dll")
$fichier_ini = "C:\Program Files\MonoChrome Softworks\Serializer\Template\TTL_1_0000_00.ini"
$file_save = ("C:\Program Files\MonoChrome Softworks\Serializer\Results\TTL-"&@MDAY&@MON&".txt")
$fin_saisie= ""
$i=1
$k=10
Dim $champs[11][3]
_init()
#Region ### START Koda GUI section ### Form=
GUICreate("Serializer", 402, 477, 537, 123)
GUICtrlCreateLabel($champs[1][0], 89, 112, 252, 43)
GUICtrlSetFont(-1, 20, 400, 0, "Calibri")
GUICtrlCreateGroup("", 0, 56, 401, 105)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateLabel("SAISIE S/N", 114, 8, 172, 43)
GUICtrlSetFont(-1, 24, 400, 0, "Calibri")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateLabel("RELEVEZ LE S/N DE", 76, 72, 249, 43)
GUICtrlSetFont(-1, 24, 400, 0, "Calibri")
GUICtrlCreateGroup("Récapitulatif de la saisie de numéros de série", 0, 168, 401, 265)
GUICtrlCreateGroup("", -99, -99, 1, 1)
_attentechamps()
$test = GUICtrlCreateInput("", 120,120,1,1)
GUICtrlSetState($test,$GUI_FOCUS+$GUI_HIDE)
GUISetState(@SW_SHOW)
$fin_saisie_btn = GUICtrlCreateButton("Terminer la saisie (à la fin de ce relevé)", 192, 440, 209, 33)
$effac_btn = GUICtrlCreateButton("Effacer la saisie en cours", 0, 440, 185, 33)
#EndRegion ### END Koda GUI section ###
;~ ---------------------------------------------------------------------------------------------------
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $fin_saisie_btn
$fin_saisie="1"
GUICtrlSetState($test,$GUI_FOCUS+$GUI_HIDE)
Case $effac_btn
$i = $i - 1
If $i < 1 Then
MsgBox(0,"","Il n'y a plus de valeurs à effacer.")
$i = 1
GUICtrlSetState($test,$GUI_FOCUS+$GUI_HIDE)
Else
$champs[$i][1] = "en attente ..."
_attentechamps()
GUICtrlSetState($test,$GUI_FOCUS+$GUI_HIDE)
EndIf
EndSwitch
Select
Case _IsPressed("0D",$dll)=1
If $champs[$i][1] <> "en attente ..." Then
Sleep(500)
$i = $i + 1
Else
$champs[$i][1]=GUICtrlRead($test)
GUICtrlSetData($test,"")
GUICtrlCreateLabel($champs[$i+1][0], 89, 112, 252, 43)
GUICtrlSetFont(-1, 20, 400, 0, "Calibri")
_attentechamps()
EndIf
EndSelect
If $champs[$i][0] = "" Then
SplashTextOn("", "Enregistrement ...", 400, 50, -1, -1, 33, -1, 18)
$file = FileOpen($file_save, 1)
FileWrite($file,$champs[1][1]&";"&$champs[2][1]&";"&$champs[3][1]& @CRLF)
FileClose($file)
$i = "1"
Sleep(1000)
If $fin_saisie = 1 Then Exit
_init()
_attentechamps()
SplashOff()
EndIf
WEnd
;~ ---------------------------------------------------------------------------------------------------
Func _attentechamps()
$champs1 = GUICtrlCreateLabel($champs[1][0] & $champs[1][2] & $champs[1][1], 8, 192, 181, 17)
$champs2 = GUICtrlCreateLabel($champs[2][0] & $champs[2][2] & $champs[2][1], 8, 216, 181, 17)
$champs3 = GUICtrlCreateLabel($champs[3][0] & $champs[3][2] & $champs[3][1], 8, 240, 181, 17)
$champs4 = GUICtrlCreateLabel($champs[4][0] & $champs[4][2] & $champs[4][1], 8, 264, 181, 17)
$champs5 = GUICtrlCreateLabel($champs[5][0] & $champs[5][2] & $champs[5][1], 8, 288, 181, 17)
$champs6 = GUICtrlCreateLabel($champs[6][0] & $champs[6][2] & $champs[6][1], 8, 312, 181, 17)
$champs7 = GUICtrlCreateLabel($champs[7][0] & $champs[7][2] & $champs[7][1], 8, 336, 181, 17)
$champs8 = GUICtrlCreateLabel($champs[8][0] & $champs[8][2] & $champs[8][1], 8, 360, 181, 17)
$champs9 = GUICtrlCreateLabel($champs[9][0] & $champs[9][2] & $champs[9][1], 8, 384, 181, 17)
$champs10 = GUICtrlCreateLabel($champs[10][0] & $champs[10][2] & $champs[10][1], 8, 408, 181, 17)
EndFunc
;~ ---------------------------------------------------------------------------------------------------
Func _init()
Dim $champs[11][3]
$j=0
Do
$j = $j+1
$champs[$j][0] = IniRead($fichier_ini, "CHAMPS", "champs"&$j, "")
If $champs[$j][0] <> "" Then
$champs[$j][1] = "en attente ..."
$champs[$j][2] = " : "
EndIf
Until $j = 10
GUICtrlCreateLabel($champs[1][0], 89, 112, 252, 43)
GUICtrlSetFont(-1, 20, 400, 0, "Calibri")
EndFunc
Code : Tout sélectionner
[CHAMPS]
champs1=BEETLE/M-II+ H1
champs2=EPSON TM-H6000 IV
champs3=MAGELLAN 1100i
champs4=
champs5=
champs6=
champs7=
champs8=
champs9=
champs10=