FranckB Posted June 25, 2008 Posted June 25, 2008 Im trying to make easier the installation of software.In a combo you can choose the model of machine.In a list you can choose the different applications you want to add.You can write in an ini file the 2 lists. So if you want to add a program you write it in the ini file (you dont change the script (or exe)). But that does not work properly.Can someone help me ?expandcollapse popup#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, $ochoix, $cchoix, $ListOption;, $modl Dim $modl ;-------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 ;--------list------------------------------------------------------- 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") ;------------------------------------------------------------------- ;---------- functions---------------------------------------------- ;------------------------------------------------------------------- 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() For $i = 1 To $ListOption[0] If $oneshot[$i][0]=$ListOption[$i] then runwait @ScriptDir & $oneshot[$i][1] Next $modl = IniReadSection("lance.ini", $sItems) For $i = 1 To $modl[0] runwait @ScriptDir & $modl[$i][1] Next EndFunc Func SelectionMod($ListOption) $reponse = MsgBox (4, "Confirmation", "Are you sure you want to install : " & @CRLF & $ListOption & $sItems) If $reponse=7 then WinClose ("Confirmation") If $reponse=6 then Action() EndFunc While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit WendHere the ini file :;-------How to-------------------------------------------------------------; Value name is the frienly name of the component to install.; The value is the file name without the drive-letter. ; Program will append the drive letter where this program was launched.; To supply parameter, enter ";" (semi-colon) after the file name followed; by the parameter value.; ;-------Example------------------------------------------------------------; Install Bidule=ref\Bidule\V1.2\Bidule-V1.2.msi;/qb![Oneshot]Adobe Reader 8=ref\Adobe\AdbReader.msi;/r /t:2Foxit Reader 2.2 =ref\Foxit\FoxitReader.exe;/silentCD Burner XP Pro=ref\cdbxppro\cdbxp_setup_4.0.024.439.exeDeep Burner=ref\DeepBurner\DeepBurner.exe;-F2c:\logs\truc.logPDF Creator=ref\PDFCreator\PDFCreator-0_9_5_setup.exe[Models]desktop=pc_desktoplaptop=pc_laptopHP NC6400 only=NC6400;--------Models----------------------------------------------------[pc_desktop]dirfixe=ref\desktop\initialkb2.msi;/i[pc_laptop]dirportable=ref\laptop\initialkb0.msi;/iwifi=ref\laptop\enablewifi.msi[NC6400]HP SYNAPTICSTOUCHPAD V8.2=ref\HPSYNAPTICSTOUCHPAD\V8.2\Setup.exe; -S -F2c:\logs\HPSYNAPTICSTOUCHPAD-V8.2.logHP MOBILE DATA PROTECTION SYSTEM=ref\HPMOBILEDATAPROTECTIONSYSTEM\V1\setup.exe; -S -F2c:\logs\HPMOBILEDATAPROTECTIONSYSTEM-V1.logHP Quick Launch V6=ref\HPQuickLaunch\V6\setup.exe; -S -F2c:\logs\HPQuickLaunch-V6.logBe indulgent for my English.Thanks for your help.
Triblade Posted June 25, 2008 Posted June 25, 2008 What exacly does not work then? And is this part: For $i = 1 To $modl[0] runwait @ScriptDir & $modl[$i][1] Next Isn't this: $modl[0] Supposed to be: $modl[0][0] My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger)
FranckB Posted June 25, 2008 Author Posted June 25, 2008 What exacly does not work then? And is this part: For $i = 1 To $modl[0] runwait @ScriptDir & $modl[$i][1] Next Isn't this: $modl[0] Supposed to be: $modl[0][0] In the "Func Action()", I need to runwait each value corresponding to the key that is highlight. I can display the list of keys in : Func SelectionMod($ListOption) $reponse = MsgBox (4, "Confirmation", "Are you sure you want to install : " & @CRLF & $ListOption & $sItems) If $reponse=7 then WinClose ("Confirmation") If $reponse=6 then Action() EndFunc But not the corresponding values. otherwise OK for the $modl[0][0].
FranckB Posted June 25, 2008 Author Posted June 25, 2008 I found ! it works. expandcollapse popup#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 Just replace Msgbox by Runwait in the ligns "REPLACE MSGBOX WITH RUNWAIT". I hope that this will be useful to someone. Bye. Franckb.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now