Kleiner Posted August 15, 2005 Posted August 15, 2005 Hello, I wrote a program which helps finishing the configuration of a Windows PC. Using a basic image, certain applications, batchfiles, regfiles etc. have to be installed/executed to get the PC ready. Since these "updates" are different depending on the machine and the purpose of the usage of the pc, each installation is different. Therefor the program has a gui with ~30 checkboxes each standing for a setup-routine, a batchfile, regfile etc. automated by using an autoit-script. Hitting the Install-Button runs the selected scripts and the configuration of the pc gets finished. Now, I would like to optimize the code using an array. As for now, I realize this using the following code (working, but very long (~30 checkboxes) and not very comfortable): GUISetState (@SW_SHOW) $msg = 0 While $msg <> -3 $msg = GuiGetMsg() Select case $msg = $BUTTON_Install if GuiCtrlRead($CHECKBOX_BGInfo) = 1 Then Runwait("_installscript_bginfo.bat") GUICtrlSetState ($CHECKBOX_BGInfo,$GUI_UNCHECKED) GUICtrlSetColor($CHECKBOX_BGInfo,0x00bb00) EndIf if GuiCtrlRead($CHECKBOX_NWPrinter) = 1 Then Runwait("_installscript_columbus_d.exe") GUICtrlSetState ($CHECKBOX_NWPrinter,$GUI_UNCHECKED) GUICtrlSetColor($CHECKBOX_NWPrinter,0x00bb00) EndIf If GuiCtrlRead($CHECKBOX_NewSID) = 1 Then Runwait("_installscript_newsid.exe") GUICtrlSetState ($CHECKBOX_NewSID,$GUI_UNCHECKED) GUICtrlSetColor($CHECKBOX_NewSID,0x00bb00) EndIf If GuiCtrlRead($CHECKBOX_WinUpdates) = 1 Then Runwait("_installscript_regfile_windows_updates.exe") GUICtrlSetState ($CHECKBOX_WinUpdates,$GUI_UNCHECKED) GUICtrlSetColor($CHECKBOX_WinUpdates,0x00bb00) EndIf ..... ..... EndSelect Wend Using for and an array should work and could look someting like this(?): Dim $checkbox[3] $checkbox[1]="$CHECKBOX_WinUpdates" $checkbox[2]="$CHECKBOX_PicShortcuts" $checkbox[3]="$CHECKBOX_Newsid" Dim $installscript[3] $installscript[1]="$_installscript_winupdates.exe" $installscript[2]="$_installscript_picshortcuts.exe" $installscript[3]="$_installscript_newsid.exe" For $i = 1 to 3 If GuiCtrlRead($checkbox[i]) = 1 Then Runwait($installscript[i]) GUICtrlSetState ($checkbox[i],$GUI_UNCHECKED) GUICtrlSetColor($checkbox[i],0x00bb00) EndIf Next Unfortunatly the syntax is wrong and I can`t figure out why. Any suggestions/ideas? Thanks in advance Steffen
GaryFrost Posted August 15, 2005 Posted August 15, 2005 Haven't written a script to check this against, but should be pretty close to what your trying to do: Dim $checkbox[4] $checkbox[0] = 3 $checkbox[1]= GUICtrlCreateCheckbox("WinUpdates",10,10) $checkbox[2]=GUICtrlCreateCheckbox("PicShortcuts",10,30) $checkbox[3]=GUICtrlCreateCheckbox("Newsid",10,50) Dim $installscript[4] $installscript[0] = 3 $installscript[1]="$_installscript_winupdates.exe" $installscript[2]="$_installscript_picshortcuts.exe" $installscript[3]="$_installscript_newsid.exe" For $i = 1 to $checkbox[0] If GuiCtrlRead($checkbox[$i]) = 1 Then Runwait($installscript[$i]) GUICtrlSetState ($checkbox[$i],$GUI_UNCHECKED) GUICtrlSetColor($checkbox[$i],0x00bb00) EndIf Next SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Kleiner Posted August 15, 2005 Author Posted August 15, 2005 Haven't written a script to check this against, but should be pretty close to what your trying to do:If GuiCtrlRead($checkbox[$i]) = 1 Then Runwait($installscript[$i])<{POST_SNAPBACK}>Thank you very much, the $i instead of i was the solution.
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