lucius100 Posted February 26, 2015 Share Posted February 26, 2015 I am trying to make unattended installer, and here is some GUI example expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Test", 237, 89, 369, 423) $Checkbox1 = GUICtrlCreateCheckbox("Install CCleaner", 8, 8, 97, 17) $Checkbox2 = GUICtrlCreateCheckbox("Install Yahoo", 8, 32, 97, 17) $Checkbox3 = GUICtrlCreateCheckbox("Install Antivirus", 8, 56, 97, 17) $Button1 = GUICtrlCreateButton("Start", 136, 48, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _Start() Case $Checkbox1 _install1() Case $Checkbox2 _install2() Case $Checkbox3 _install3() EndSwitch WEnd Func _install1() Run ("install1.exe") EndFunc Func _install2() Run ("install2.exe") EndFunc Func _install3() Run ("install3.exe") EndFunc I assign the task to each checkbox, and then I press the start, it will run the task with box checked only. Is it possible? Link to comment Share on other sites More sharing options...
Solution Radiance Posted February 26, 2015 Solution Share Posted February 26, 2015 Here you go, just retrieve the value of the checkboxes and call your functions accordingly. 1 means it's checked, 4 means it's unchecked. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Test", 237, 89, 369, 423) $Checkbox1 = GUICtrlCreateCheckbox("Install CCleaner", 8, 8, 97, 17) $Checkbox2 = GUICtrlCreateCheckbox("Install Yahoo", 8, 32, 97, 17) $Checkbox3 = GUICtrlCreateCheckbox("Install Antivirus", 8, 56, 97, 17) $Button1 = GUICtrlCreateButton("Start", 136, 48, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetState($Button1, $GUI_DISABLE) If GUICtrlRead($Checkbox1) = 1 Then _install1() If GUICtrlRead($Checkbox2) = 1 Then _install2() If GUICtrlRead($Checkbox3) = 1 Then _install3() GUICtrlSetState($Button1, $GUI_ENABLE) EndSwitch WEnd Func _install1() Run ("install1.exe") EndFunc Func _install2() Run ("install2.exe") EndFunc Func _install3() Run ("install3.exe") EndFunc Link to comment Share on other sites More sharing options...
Radiance Posted February 26, 2015 Share Posted February 26, 2015 I should add that using Run() instead of RunWait() might be a bad idea since the script won't wait until your installers finish and will run all 3 .exes almost simultaneously. Unless that is what you want. Link to comment Share on other sites More sharing options...
lucius100 Posted February 26, 2015 Author Share Posted February 26, 2015 I should add that using Run() instead of RunWait() might be a bad idea since the script won't wait until your installers finish and will run all 3 .exes almost simultaneously. Unless that is what you want. Thanks, will try it later Link to comment Share on other sites More sharing options...
lucius100 Posted February 26, 2015 Author Share Posted February 26, 2015 Here you go, just retrieve the value of the checkboxes and call your functions accordingly. 1 means it's checked, 4 means it's unchecked. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Test", 237, 89, 369, 423) $Checkbox1 = GUICtrlCreateCheckbox("Install CCleaner", 8, 8, 97, 17) $Checkbox2 = GUICtrlCreateCheckbox("Install Yahoo", 8, 32, 97, 17) $Checkbox3 = GUICtrlCreateCheckbox("Install Antivirus", 8, 56, 97, 17) $Button1 = GUICtrlCreateButton("Start", 136, 48, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetState($Button1, $GUI_DISABLE) If GUICtrlRead($Checkbox1) = 1 Then _install1() If GUICtrlRead($Checkbox2) = 1 Then _install2() If GUICtrlRead($Checkbox3) = 1 Then _install3() GUICtrlSetState($Button1, $GUI_ENABLE) EndSwitch WEnd Func _install1() Run ("install1.exe") EndFunc Func _install2() Run ("install2.exe") EndFunc Func _install3() Run ("install3.exe") EndFunc Another thing I forget to ask, how to create a message box say success or whatever, if all the task is done? Link to comment Share on other sites More sharing options...
Radiance Posted February 26, 2015 Share Posted February 26, 2015 Check out the section below $Button1 and try to understand what the script is doing here: - Button gets disabled so you can't press it again while the installers are running (might lead to unwanted effects) - this is only cosmetic. - (Optional) Installer 1 runs - (Optional) Installer 2 runs - (Optional) Installer 3 runs - Button gets enabled so you could use it again. If you want a message box, add it right after the above part. Link to comment Share on other sites More sharing options...
lucius100 Posted February 26, 2015 Author Share Posted February 26, 2015 k, works perfectly Link to comment Share on other sites More sharing options...
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