Code : Tout sélectionner
#include <GuiConstants.au3>
#include <GUIListBox.au3>
#include <GuiComboBoxEx.au3>
Opt("GUIOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE, "Cancel")
$model = IniReadSection("lance.ini", "Models")
$oneshot = IniReadSection("lance.ini", "Oneshot")
;-------------------------------------------------------------------
;----------GUI------------------------------------------------------
;-------------------------------------------------------------------
GuiCreate("Installer", 600, 450)
GUISetState ()
Local $liste, $sItems, $aItems, $ListOption, $ret, $listmodel
;-------combo-------------------------------------------------------
GuiCtrlCreateLabel("Select the machine model :", 10, 25)
If @error Then
MsgBox(4096, "", "Error ! Check for INI file.")
Else
$combo = GUICtrlCreateCombo("", 10, 45, 580, 100)
For $i = 1 To $model[0][0]
GUICtrlSetData($combo, $model[$i][0])
Next
EndIf
;--------liste------------------------------------------------------
GuiCtrlCreateLabel("Select the applications to install (press CTRL to select multiple applications) :", 10, 130)
If @error Then
MsgBox(4096, "", "Error ! Check for INI file.")
Else
$liste = GuiCtrlCreateList("", 10, 150, 580, 250, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL))
For $i = 1 To $oneshot[0][0]
GUICtrlSetData($liste, $oneshot[$i][0])
Next
EndIf
;-------------------------------------------------------------------
$bouton_Activate = GuiCtrlCreateButton("OK", 100, 405, 100, 30)
$bouton_Cancel = GuiCtrlCreateButton("Cancel", 400, 405, 100, 30)
GUICtrlSetState ( $bouton_Activate, $GUI_ENABLE)
GUICtrlSetOnEvent($bouton_Activate, "Activate")
GUICtrlSetOnEvent($bouton_Cancel, "Cancel")
;-------------------------------------------------------------------
;--------Les fonctions----------------------------------------------
;-------------------------------------------------------------------
Func Activate()
$aItems = _GUICtrlListBox_GetSelItemsText ($liste)
For $iI = 1 To $aItems[0]
$sItems &= @LF & $aItems[$iI]
Next
SelectionMod(GUICtrlRead ($combo))
EndFunc
Func Cancel()
Exit
EndFunc
Func Action()
$var = IniRead("lance.ini", "Models", $listmodel, "NotFound")
$varpc = IniReadSection("lance.ini", $var)
If @error Then
MsgBox(4096, "Caution", "Error occurred, probably no INI file.")
Else
For $i = 1 To $varpc[0][0]
MsgBox(4096, $varpc[$i][0], $varpc[$i][1]) ; REPLACE MSGBOX WITH RUNWAIT
Next
$aItems = _GUICtrlListBox_GetSelItemsText ($liste)
For $i = 1 To $aItems[0]
For $x = 1 To $oneshot[0][0]
If $aItems[$i] = $oneshot[$x][0] Then MsgBox(4096, $oneshot[$x][0], $oneshot[$x][1]) ; REPLACE MSGBOX WITH RUNWAIT
Next
Next
EndIf
MsgBox(4096, "Fin", "Fin")
EndFunc
Func SelectionMod($ListOption)
$var = IniRead("lance.ini", "Models", $ListOption, "NotFound")
$varpc = IniReadSection("lance.ini", $var)
If @error Then
MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
For $i = 1 To $varpc[0][0]
$ret=$ret & @CRLF & $varpc[$i][0]
Next
EndIf
$listmodel=$ListOption
$tous = $ret & $sItems
$reponse = MsgBox (4, "Confirmation", "Are you sure you want to install : " & @CRLF & $tous & @CRLF & @CRLF & "?")
For $iI = 1 To $tous
MsgBox(4096, "Tous", $aItems[$iI])
Next
If $reponse=7 then WinClose ("Confirmation")
If $reponse=6 then Action()
EndFunc
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then Exit
Wend