Code : Tout sélectionner
#include <WindowsConstants.au3>
#include <GUIListBox.au3>
#include <GuiStatusBar.au3>
#include <GuiListView.au3>
;Génération du fichier Liste (Ce fichier n'est pas généré dans le script d'origine)
FileOpen(@ScriptDir&"\liste.txt",2)
FileWrite(@ScriptDir&"\liste.txt","Démarrage"&@CRLF&"Exécution du batch"&@CRLF&"Recherche txt"&@CRLF&"copie de ficheir"&@CRLF&"Fin ")
FileClose(@ScriptDir&"\liste.txt")
Func _itemstart()
$Label1 = GUICtrlCreateLabel("Tâche en cours : "&$listmsg[$i], 150, 16, 232, 28)
GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif")
sleep(1000)
EndFunc
Func _itemadd($percent,$ret)
$item1=GUICtrlCreateListViewItem($listmsg[$i], $listview)
GUICtrlSetData($Progress1 , $percent)
_GUICtrlStatusBar_SetText($StatusBar1, "Etat d'avancement: "&$percent&"%")
if $ret = 0 Then
GUICtrlSetData($item1,"|OK")
Else
GUICtrlSetData($item1,"|NOK")
EndIf
$i=$i+1
_GUICtrlListView_ClickItem($ListView, _GUICtrlListView_GetItemCount($ListView) - 1)
EndFunc
Func _itempass($percent)
$item1=GUICtrlCreateListViewItem($listmsg[$i], $listview)
GUICtrlSetData($Progress1 , $percent)
_GUICtrlStatusBar_SetText($StatusBar1, "Etat d'avancement: "&$percent&"%")
GUICtrlSetData($item1,"|-")
$i=$i+1
EndFunc
Global $Form2, $Progress1, $List1, $Label1, $Button1, $Button2, $StatusBar1
$Form2 = GUICreate("Déploiement EAR", 533, 332, -1, -1)
$Progress1 = GUICtrlCreateProgress(191, 288, 150, 17)
;~ GUICtrlSetStyle($Progress1,0x040A)
GUICtrlSetFont(-1, 4, 400, 0, "MS Sans Serif")
$listview = GUICtrlCreateListView("Description|Status", 21, 59, 497, 188, BitOR($LBS_NOTIFY,$WS_VSCROLL,$WS_BORDER))
GUICtrlSendMsg(-1, 0x101E, 0, 420)
GUICtrlSendMsg(-1, 0x101E, 1, 50)
$Label1 = GUICtrlCreateLabel("En cours de déploiement...", 150, 16, 232, 28)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Lancer", 169, 255, 67, 25)
$Button2 = GUICtrlCreateButton("Arreter", 296, 255, 67, 25)
$StatusBar1 = _GUICtrlStatusBar_Create($Form2)
GUISetState(@SW_SHOW)
;-----------------------------------------------------------------------------------------------------------
;Récupération étapes
$string = FileRead(@ScriptDir&"\liste.txt")
$listmsg = StringSplit($string,@LF)
For $i = 1 to $listmsg[0]
$listmsg[$i] = StringTrimRight($listmsg[$i], 1)
Next
$i=1
;-----------------------------------------------------------------------------------------------------------
$begin = TimerInit()
While 1
sleep(10)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button1
#region
;0% = Démarrage-----------------------------------------------------------------------------------------------------------
_itemstart()
_itemadd(0,0)
#endregion
#region
;25% = Exécution du batch-----------------------------------------------------------------------------------------------------------
_itemstart()
if runWait("batchs\bonjour.bat")=0 Then
_itemadd(1,0)
else
_itemadd(1,1)
_break()
EndIf
#endregion
#region
;50% = Recherche fichier TXT-----------------------------------------------------------------------------------------------------------
_itemstart()
$cpt=0
$search = FileFindFirstFile("temp\*.txt")
; Check if the search was successful
If $search = -1 Then
_itempass(50)
Else
While 1
$file = FileFindNextFile($search)
If @error Then
ExitLoop
_itemadd(50,1)
Else
If $cpt=0 Then
_itemadd(50,0)
EndIf
$txtfile=$file
$cpt=$cpt+1
EndIf
WEnd
$txtfile="temp\"&$txtfile
EndIf
; Close the search handle
FileClose($search)
#endregion
#region
;75% = Recherche fichier TXT-----------------------------------------------------------------------------------------------------------
_itemstart()
FileCopy(@ScriptDir & "\data\pool.xml", "D:\perso\pool.xml")
If @error<>0 Then
_itemadd(75,1)
Else
_itemadd(75,0)
EndIf
#endregion
#region
;75% = Fin-----------------------------------------------------------------------------------------------------------
_itemstart()
_itemadd(100,0)
#endregion
Case $Button2, $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd