Jump to content

combo boxes to run scripts


am632
 Share

Recommended Posts

Hi, I have about 6 scripts that auto install 6 different bits of software (avg, openoffice, etc)

I would like a simple gui with radio buttons, so you can tick the ones you want to install then click a run button.

I have no idea where to start and Im not finding anything on the forum that seems to be what i need.

please can anyone help?

Edited by am632
Link to comment
Share on other sites

#include <GUIConstantsEx.au3>

Local $hGUI, $Combo, $Btn
Local $msg
$hGUI = GUICreate("My GUI combo", 300, 70)
$Combo = GUICtrlCreateCombo("AVG", 10, 12, 200, 25)
GUICtrlSetData(-1, "OpenOffice|ETC")
$Btn = GUICtrlCreateButton("Test", 220, 12, 70, 25)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
            
        Case $Btn
            Switch GUICtrlRead($Combo)
                Case "avg"
                    ConsoleWrite("Installing AVG..." & @CRLF)
                    
                Case "openoffice"
                    ConsoleWrite("Installing your office..." & @CRLF)
                    
                Case "ETC"
                    ConsoleWrite("Installing ETC..." & @CRLF)
                    
                Case Else
                    ConsoleWrite("Unknown selection.." & @CRLF)
            EndSwitch
    EndSwitch
WEnd

Read the help file, it's from there but modified for your case.

Link to comment
Share on other sites

  • Moderators

am632,

Why combo boxes? I would think "about 6" checkboxes and a "Go" button would do the job nicely. :) You would need to see which checkboxes were ticked by using GUICtrlRead ad then run the associated scripts.

I see you have edited your post while I was typing. Radios would be as good as checkboxes - but do not use a group or you will only be able to select one at a time. ;)

Give it a go yourself and come back if you have problems.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks guys, after research and tutorials I now have a working script, and here it is....

msgbox(0, "Warning", "Please close any other applications before using this software")
#include <GUIConstants.au3>
Opt("TrayIconHide", 1)
GUICreate("Main Menu", 450, 320, 310, 190)
GUICtrlCreateLabel("Select your Applications: ", 40, 20)
$opt1 = GUICtrlCreateCheckbox("AVG 8.5 Free", 80, 50)
$opt2 = GUICtrlCreateCheckbox("OpenOffice 3.1.1", 80, 70)
$opt3 = GUICtrlCreateCheckbox("Adobe Flash Player", 80, 90)
$opt4 = GUICtrlCreateCheckbox("Ashampoo Burning Studio 6 FREE", 80, 110)
$opt5 = GUICtrlCreateCheckbox("VLC Media Player 1.0.3", 80, 130)
$opt6 = GUICtrlCreateCheckbox("Firefox 3.5.5", 80, 150)
$opt7 = GUICtrlCreateCheckbox("Play Complete Sound", 180, 190)
$exit = GUICtrlCreateButton("Exit", 240, 240, 60)
$Option = GUICtrlCreateButton("Start", 150, 240, 60)
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
    If $msg = $exit Then
        Exit
    Elseif $msg = $Option Then
        If GUICtrlRead($opt1) = 1 Then
            Run("DATA\AVG8-5.exe")
            ProcessWaitClose("AVG8-5.exe")
        EndIf
If GUICtrlRead($opt2) = 1 Then
            Run("DATA\OpenOffice_3-1-1_USB_Install-XP.exe")
            ProcessWaitClose("OpenOffice_3-1-1_USB_Install-XP.exe")
        EndIf
        If GUICtrlRead($opt3) = 1 Then
            Run("DATA\Flashinstall.exe")
            ProcessWaitClose("Flashinstall.exe")
        EndIf
        If GUICtrlRead($opt4) = 1 Then
            Run("DATA\ashampooinstall.exe")
            ProcessWaitClose("ashampooinstall.exe")
        EndIf
        If GUICtrlRead($opt5) = 1 Then
            Run("DATA\vlc-1-0-3.exe")
            ProcessWaitClose("vlc-1-0-3.exe")
        EndIf
        If GUICtrlRead($opt6) = 1 Then
            Run("DATA\firefox-3-5-5.exe")
            ProcessWaitClose("firefox-3-5-5.exe")
        EndIf
       If GUICtrlRead($opt7) = 1 Then
            SoundPlay ("finished.wav",1)
        EndIf

EndIf
WEnd
Link to comment
Share on other sites

  • Moderators

am632,

$opt1 = GUICtrlCreateCheckBox{......)
GUICtrlSetState(-1, $GUI_CHECKED) ; place after each creation line, -1 means last created control

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thank you very much, appreciate your help

When you get the point of being tired of updating your script I would suggest reading from an Ini file to get the value of the AppName and the Path. So when you want to change it you don't have to update the script and recompile it. You just update the ini file and the AutoIT app is never touched.

I started where you are because I wanted to run installs back to back but I quickly out grew having to modify the code. My first app was very basic. After a while I it got more efficient and due to learning how to use Arrays I took my app down from over 3000 lines of code to just a little above 900 on version 2. The app will dynamically create the check boxes and label based on what I put in the ini file. Get real familiar with Arrays, StringSplit etc. I used to hate Arrays because I feared them. LOL Now I use them for most things cause of efficiency. My app will run each app/script, then when that is done it will start the next one and so on and out put it to the console so I see what's going on. It has 3 other tabs that do stuff too. So something for you to look forward to down the road. I finished this in April 07. Took me many months to get it to where it is. Here is pic of my app. :)

Posted Image

EndFuncAutoIt is the shiznit. I love it.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...