Jump to content
rakesh2804

How to create a GUI to Choose and install application for the chosen catagory?

Recommended Posts

rakesh2804

Hi,

I am new to AutoIT and coding

Short version:

a. I want to create a GUI such that there is a drop down list where I can choose one among many categories.

b. After selecting a category, I should get a Pop up windows showing many applications, where I can check (tick mark) the applications and make it automatically install them.

Long version:

I want to create a pop up window with drop down list containing  names of multiple department in my organization. After selecting a particular department (for example IT), I need to get another pop up window showing the list of application , for example (Office, Antivirus) etc. where I can select whichever applications I want and then let the applications install automatically.

It would also be better if I can get another pop up prior to installing the applications to choose the variants, for example (Office 64-bit and 32-bit).

 

Please help

 

Share this post


Link to post
Share on other sites
KickStarter15
Posted (edited)
4 hours ago, rakesh2804 said:

a. I want to create a GUI such that there is a drop down list where I can choose one among many categories.

Have tried looking at Help file? try checking with GUICtrlCreateCombo() and see if that's what you want.

 

4 hours ago, rakesh2804 said:

b. After selecting a category, I should get a Pop up windows showing many applications, where I can check (tick mark) the applications and make it automatically install them.

Is there any coding you've made for this? post it and will see how we can help you with the GUI pop-up you want.;)

 

Edit: Create you own version of coding and post it here so we can start checking and help you more. Help file is a friendly stuff, so check on it and compose your code.

Edited by KickStarter15
  • Thanks 1

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Share this post


Link to post
Share on other sites
rakesh2804
42 minutes ago, KickStarter15 said:

Have tried looking at Help file? try checking with GUICtrlCreateCombo() and see if that's what you want.

 

Is there any coding you've made for this? post it and will see how we can help you with the GUI pop-up you want.;)

 

Edit: Create you own version of coding and post it here so we can start checking and help you more. Help file is a friendly stuff, so check on it and compose your code.

Hi Kickstarter15,

 

Thank you. The Help file is rather user friendly but still it is still difficult for a noob like my myself to understand. 

I was wondering if I could get a basic example (set of consecutive codes) on how I can achieve my task, that way I can implement and also learn with the process.

So far, I have googled and found that I can implement GUICtrlCreateCombo() to create a drop down list, but still I wanted to know stuff like

- how I can insert text on top of the drop down box? *(Attachment for reference)

- how to increase the size of that text?

etc.

here is the code:

#include <GUIConstantsEx.au3>

Global $hGUI, $ctrlCombo

$hGui = GUICreate("Department", 300, 150)
$ctrlCombo = GUICtrlCreateCombo("All", 10, 10)
GUICtrlSetData(-1, "IT|Finance|Operation|HR|Procurement|Projects", "All")
$ctrlButton = GUICtrlCreateButton("SET Finance", 100, 250, 100, 30)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $ctrlButton
            ControlCommand($hGui, "", $ctrlCombo, "SelectString", "Finance")
    EndSwitch
WEnd

 

 

Autoit.jpg

Share this post


Link to post
Share on other sites
Zedna
Posted (edited)
#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>

Global $hGUI, $ctrlCombo

$hGui = GUICreate("Department", 300, 150)
GUICtrlCreateLabel("Choose a Department", 10, 10, 200, 25)
GUICtrlSetFont(-1, 12)
$ctrlCombo = GUICtrlCreateCombo("All", 10, 35, 200, 25, BitOr($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData(-1, "IT|Finance|Operation|HR|Procurement|Projects", "All")
GUICtrlSetFont(-1, 12)
$ctrlButton = GUICtrlCreateButton("SET Finance", 100, 75, 100, 30)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $ctrlButton
            ControlCommand($hGui, "", $ctrlCombo, "SelectString", "Finance")
    EndSwitch
WEnd

 

For choosing of list of applications for cathegory use Listview (with checkboxes).

EDIT: You can use Koda Form Designer - it's visual GUI editor which will generate apropriate AU3 code fo you

 

Edited by Zedna
  • Thanks 1

Share this post


Link to post
Share on other sites
KickStarter15

@rakesh2804,

Here's a starting code for you.;)

#include <GUIConstantsEx.au3>

Global $hGUI, $ctrlCombo

$hGui = GUICreate("Department", 250, 120)
$ctrlCombo = GUICtrlCreateCombo("All", 10, 35)
GUICtrlSetData(-1, "IT|Finance|Operation|HR|Procurement|Projects", "All")
$ctrlButton = GUICtrlCreateButton("SET Finance", 10, 60, 110, 30)
$Label = GUICtrlCreateLabel("Choose a Department", 10, 10, 200)
GUICtrlSetFont(-1, 12, 800, 4) ; 12 is the font size, 800 is a bold font, 4 is the underline, 

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $ctrlButton
            $sComboRead = GUICtrlRead($ctrlCombo)
            MsgBox(0, "", "The combobox is currently displaying: " & $sComboRead, 0, $hGUI)
            ; You can start your searching of whatever you want to do... those pop-up things.
            ; Just $sComboRead as your value to get what you want.
    EndSwitch
WEnd

If you want to have a it working then detailed all your needs and we'll try to compose one.:)

  • Thanks 1

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Share this post


Link to post
Share on other sites
Subz

Here is another method, sorry codes a bit of a mess, just threw it together.

#cs
## Save Installs.ini to the same folder as your script ##
[Department]
All = Section All
Finance = Section Finance
HR = Section HR
IT = Section IT
Operation = Section Operation
Procurement = Section Procurement
Projects = Section Projects

[Section All]
Adobe Reader = Key - Adobe Reader
Adobe Flash = Key - Adobe Flash
Java Runtime = Key - Java Runtime

[Section Finance]
Adobe Flash = Key - Adobe Flash
Java Runtime = Key - Java Runtime

[Section HR]
Adobe Flash = Key - Adobe Flash
Java Runtime = Key - Java Runtime

[Section IT]
Adobe Flash = Key - Adobe Flash
Java Runtime = Key - Java Runtime

[Section Operation]
Adobe Flash = Key - Adobe Flash
Java Runtime = Key - Java Runtime

[Section Procurement]
Adobe Flash = Key - Adobe Flash
Java Runtime = Key - Java Runtime

[Section Projects]
Adobe Flash = Key - Adobe Flash
Java Runtime = Key - Java Runtime

[Commands]
Key - Adobe Reader = Msiexec.exe /i "@ScriptDir@\Adobe.msi" /QN /NORESTART
Key - Adobe Flash = Msiexec.exe /i "@ScriptDir@\Flash.msi" /QN /NORESTART
Key - Java Runtime = "@ScriptDir@\JavaRuntime.exe" /s
#ce
#include <Array.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

Opt("ExpandVarStrings", 1)

Global $sIniFile = @ScriptDir & "\Installs.ini"
Global $aDeparments = IniReadSection($sIniFile, "Departments")
    If @error Then Exit
Global $_sDepartment = ""
Global $hGUI, $idDeparment, $idSubtitle, $idListView

$hGui = GUICreate("Department", 500, 190)
$idSubtitle = GUICtrlCreateLabel("Department", 10, 10, 130)
    GUICtrlSetFont(-1, 16, 400)
$idDeparment = GUICtrlCreateCombo("Select Department", 10, 40, 200, 20, $CBS_DROPDOWNLIST)
    GUICtrlSetData(-1, _ArrayToString($aDeparments, "|", 1, -1, "|", 0, 0), "Select Department")
$idListView = GUICtrlCreateListView("Product Name|Install Command", 10, 65, 480, 100)
GUISetState()
AdlibRegister("_SetDepartment")
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd
Func _SetDepartment()
    Local $aProducts, $sProducts
    Local $sDepartment = GUICtrlRead($idDeparment)
    If $_sDepartment = $sDepartment Then Return
    Switch $sDepartment
        Case "Select Department"
            _GUICtrlListView_DeleteAllItems($idListView)
            GUICtrlSetData($idSubtitle, $sDepartment)
        Case Else
            _GUICtrlListView_DeleteAllItems($idListView)
            GUICtrlSetData($idSubtitle, $sDepartment)
            $aProducts = IniReadSection($sIniFile, "Section - " & $sDepartment)
            If @error Then Return
            For $i = 1 To $aProducts[0][0]
                $sProducts = IniRead($sIniFile, "Commands", $aProducts[$i][1], "")
                GUICtrlCreateListViewItem($aProducts[$i][0] & "|" & $sProducts, $idListView)
                _GUICtrlListView_SetColumnWidth($idListView, 1, $LVSCW_AUTOSIZE_USEHEADER)
            Next
    EndSwitch
    $_sDepartment = $sDepartment
EndFunc

 

  • Thanks 1

Share this post


Link to post
Share on other sites
rakesh2804

WOW!!

Finally, a community full of people who are dedicated in helping each other.

Thanks a lot guys!. 

I will look into your suggestions and revert back.

 

Thanks again.

Share this post


Link to post
Share on other sites
rakesh2804
On 6/5/2018 at 2:58 PM, Zedna said:
#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>

Global $hGUI, $ctrlCombo

$hGui = GUICreate("Department", 300, 150)
GUICtrlCreateLabel("Choose a Department", 10, 10, 200, 25)
GUICtrlSetFont(-1, 12)
$ctrlCombo = GUICtrlCreateCombo("All", 10, 35, 200, 25, BitOr($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData(-1, "IT|Finance|Operation|HR|Procurement|Projects", "All")
GUICtrlSetFont(-1, 12)
$ctrlButton = GUICtrlCreateButton("SET Finance", 100, 75, 100, 30)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $ctrlButton
            ControlCommand($hGui, "", $ctrlCombo, "SelectString", "Finance")
    EndSwitch
WEnd

 

For choosing of list of applications for cathegory use Listview (with checkboxes).

EDIT: You can use Koda Form Designer - it's visual GUI editor which will generate apropriate AU3 code fo you

 

Hi @KickStarter15,

 

I installed Koda and found that it is more user friendly when compared to creating a GUI in Autoit. Thanks for the suggestion.

I do have a few questions though..

I created a GUI form to choose the department. Code generated form Koda is below 

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Department = GUICreate("Software Installer", 559, 251, 321, 353)
GUISetBkColor(0xFFFFFF)
$Label1 = GUICtrlCreateLabel("Choose a Department", 24, 8, 176, 27)
GUICtrlSetFont(-1, 14, 800, 0, "Calibri")
$Department = GUICtrlCreateList("", 24, 56, 193, 152, -1, 0)
GUICtrlSetData(-1, "Admin|All (Contains All the Softwares)|Finance|Health and Safety|Human Resource|Information Technology|Operations|Procurement|Projects|Warehouse")
GUICtrlSetFont(-1, 10, 800, 0, "Calibri")
$Proceed = GUICtrlCreateButton("Proceed", 272, 184, 65, 25)
GUICtrlSetFont(-1, 10, 800, 0, "Calibri")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

So, we get to choose a particular department and click on "Proceed" button to goto the next form.

I have created another sample form "Admin" with a check box to install Adobe acrobat.

So, inthe "select department form" , after selecting "admin" and clicking the proceed button, it should get directed to "admin" form where I can select applications and install them. 

So, the question is how to assign action to the buttons?

 

Thanks.

Share this post


Link to post
Share on other sites
Subz
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Proceed
            $sDepartment = GuiCtrlRead($Deparment)
            ;~ Actions here example:
            _Proceed($sDepartment)
    EndSwitch
WEnd

Func _Proceed($_sDepartment)
    Switch $_sDepartment
        Case "IT"
            Run("xyz")
        Case "Finance"
            Run("zyx")
    EndSwitch
EndFunc

 

Share this post


Link to post
Share on other sites
KickStarter15
Posted (edited)

@rakesh2804,

Slight modification from @Subz suggestion. Not sure if this is what you want.:sweating:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $Proceed
            If GuiCtrlRead($Department) = "Admin" Then
            ;~ Actions here example:
            Proceed()
            Else
            $sDepartment = GuiCtrlRead($Department)
            MsgBox(0,"Selected Item",$sDepartment)
            EndIf
    EndSwitch
WEnd

Func Proceed()
    Local $hGUI2 = GUICreate("Admin Form", 200, 100, 400, 350)
    Local $InstallBtn = GUICtrlCreateButton("Install", 10, 10, 80, 30)
    Local $Adobe = GUICtrlCreateLabel("Adobe Acrobat", 30, 53, 80, 20)
    Local $Ntpd = GUICtrlCreateLabel("Noptepad++", 30, 70, 90, 17)
    GUISetState()

    Global $Number = 2, $iCols = 2, $iSpacing = 15
    Global $DprtItms[$Number]

    For $i = 0 To $Number - 1
      $DprtItms[$i] = GUICtrlCreateCheckbox("", $iSpacing + (Int($i / $iCols)), ((18.7 * Mod($i, $iCols)) + 50), 15, 20)
    Next
   While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($hGUI2)
            ExitLoop
        Case $InstallBtn
          If GUICtrlRead($DprtItms[0]) = $GUI_CHECKED Then
            MsgBox(0,"Selection Made", "You've seleceted: 'Adobe Acrobat' for installation.")
            ; You can replace the message box with Run() function to install or open the item selected
          ElseIf GUICtrlRead($DprtItms[1]) = $GUI_CHECKED Then
            MsgBox(0,"Selection Made", "You've seleceted: 'Notepad++' for installation.")
            ; You can replace the message box with Run() function to install or open the item selected
         EndIf
      Case $DprtItms[0]
         GUICtrlSetState($DprtItms[1], $GUI_UNCHECKED)
      Case $DprtItms[1]
         GUICtrlSetState($DprtItms[0], $GUI_UNCHECKED)
       EndSwitch
   WEnd
EndFunc

 

Edited by KickStarter15

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

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

×