Sign in to follow this  
Followers 0
lucius100

Is it possible to queue the task?

7 posts in this topic

I am trying to make unattended installer, and here is some GUI example

#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?

Share this post


Link to post
Share on other sites



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.

#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

Share this post


Link to post
Share on other sites

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. :)

Share this post


Link to post
Share on other sites

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  :thumbsup:

Share this post


Link to post
Share on other sites

 

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.

#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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

k, works perfectly  :sorcerer:

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0