Jump to content

Simple GUI


Recommended Posts

I've built several automatic software install scripts for new workstation deployment. I would like to build a simple GUI

that simply list (checkboxes) the applications to install and if value =1 then run the autoit exe or au3. I haven't messed with autoit

in years and GUI wasn't in the version I last used.

I have a list of 15 or so development applications that are installed on new workstations. I don't want to site and run each one and would prefer to simple select the applications and click install. I also would like to step through the scripts

one by one. I'm sure there is a simple way of checking if a script is finished before it proceeds to the next in line. I assume it would use an array, but not sure. My main concern is the GUI though.

Any help?

Link to comment
Share on other sites

I made a process launcher similar to what you want. The only limitation is that it can only progress through the list from start to end. You can't rearrange elements while the script is running.

I used this to setup 85 laptops a couple weeks ago.

#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <TreeViewConstants.au3>
_Singleton("Automated Launcher Script")
Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
HotKeySet("^!x", "_Close");Exit on Ctrl+Alt+X

Global $ininame = "_process_launcher.ini"

If $CmdLine[0] == 1 Then
    $ininame = $CmdLine[1]

If Not FileExists($ininame) Then
    MsgBox(0x2030, "Error", "No """ & $ininame & """! Writing empty .ini file.")

Global $slist = IniReadSectionNames($ininame)
If @error == 1 Then
    MsgBox(0x2030, "Error", "Read fail for " & $ininame & "! File empty or invalid.")
Global $guiWindow = GUICreate("Process Queue", 250, 250)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Close")
Global $guiButton = GUICtrlCreateButton("OK", 85, 210, 80, 30, $BS_DEFPUSHBUTTON)
GUICtrlSetOnEvent($guiButton, "_ButtonEvent")
Global $guiLabel = GUICtrlCreateLabel("Choose programs to Install:", 10, 10, 180, 15)
Global $guiTree = GUICtrlCreateTreeView(10, 30, 230, 175, $TVS_CHECKBOXES)
Global $tItem[$slist[0] + 1]
For $i = 1 To $slist[0]
    $tItem[$i] = GUICtrlCreateTreeViewItem($slist[$i], $guiTree)


Func _ButtonEvent()
    Local $msgres = MsgBox(0x2124, "Confirm Selection", "Are you sure of your selection?", 86400, $guiWindow)
    If $msgres == 6 Then
        Local $pID, $path, $dir, $checked = False
        For $i = 1 To $slist[0]
            If BitAND(GUICtrlRead($tItem[$i]), $GUI_CHECKED) Then
                $checked = True
                $path = IniRead($ininame, $slist[$i], "path", "<no path>")
                $dir = IniRead($ininame, $slist[$i], "dir", ".\")
                $pID = Run($path, $dir, @SW_HIDE)
                If @error <> 0 Then
                    MsgBox(0x2030, "Error", "Failed to run " & $slist[$i] & ": """ & $path & """!", 86400, $guiWindow)
        If $checked Then
            MsgBox(0x2000, "Process Launcher", "Process queue finished!", 86400, $guiWindow)
            MsgBox(0x2000, "Process Launcher", "No process selected!", 86400, $guiWindow)

Func _CreateINI()
    Local $file = FileOpen($ininame, 2)
    FileWriteLine($file, ";INI file for Process Launcher")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";INI file format is:")
    FileWriteLine($file, ";[SECTION]")
    FileWriteLine($file, ";KEY = VALUE")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";Section name is label for installation script.")
    FileWriteLine($file, ";Key(s) are: Path, Dir")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";Processes are launched in succeeding order, one at a time.")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";Sample:")
    FileWriteLine($file, ";[Installer Label 1]")
    FileWriteLine($file, ";path = someprogram.exe")
    FileWriteLine($file, ";[Installer Label 2]")
    FileWriteLine($file, ";path = .\path\someprogram.exe")
    FileWriteLine($file, ";[Installer Label 3]")
    FileWriteLine($file, ";path = D:\path\someprogram.exe")
    FileWriteLine($file, ";dir = D:\path")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";Start entries here:")

Func _Close()
Edited by omikron48
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

  • Recently Browsing   0 members

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