Jump to content

Combobox help for a N00b


Recommended Posts

Hello Autoit Wizards, can you please help me with this GUI i am trying to create? Essentially I have 4 GUI's that already exist. What I am trying to do here is create a GUI that has a dropdown box with all the names of the 4 GUIs and when a user selects the name, it opens the corresponding GUI. I scowered the help file and couldnt find much that I could understand. Heres what I have so far.

#include <ComboConstants.au3>

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Test", 613, 431, 192, 132)

$Combo1 = GUICtrlCreateCombo("Combo1", 120, 32, 385, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))

GUICtrlSetData(-1, "script1|script2|script3|script4")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Combo1

EndSwitch

WEnd

Link to comment
Share on other sites

Create a button to process the request to access the new GUI. When the button is pressed, setup a switch/case for the button function with the GUICtrlRead() input of the combobox as the switch, and the other GUI names as your cases. Then setup functions for the other GUI creations.

EDIT: And round out your GUI size to 'flatter' numbers. It gets really annoying once you start trying to line up controls having a width of 613 =/

$GUI_Main = GUICreate("Test", 613, 431, 192, 132)
$sGuiSelect = GUICtrlCreateCombo("Select GUI", 120, 32, 385, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$bProcess = GUICtrlCreateButton("Process", 500, 380, 100, 40)
GUICtrlSetData($sGuiSelect, "script1|script2|script3|script4")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $bProcess
      _Select_Gui(GUICtrlRead($sGuiSelect))
EndSwitch
WEnd
Exit

Func _Select_Gui($sData)
    Switch $sData
        Case "script1"        
            _script1()
        Case "script2"
            _script2()
        Case "script3"
            _script3()
        Case "script4"
            _script4()
     EndSwitch
EndFunc

etc...
Edited by mechaflash213
Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to comment
Share on other sites

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Test", 613, 431, 192, 132)
$Combo1 = GUICtrlCreateCombo("script1", 120, 32, 385, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "script1|script2|script3|script4", "script1")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            Switch GUICtrlRead($Combo1)
                Case 'script1'
                    MsgBox(0,'','script1')
                Case 'script2'
                    MsgBox(0,'','script2')
                Case 'script3'
                    MsgBox(0,'','script3')
                Case 'script4'
                    MsgBox(0,'','script4')
            EndSwitch
    EndSwitch
WEnd

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

×
×
  • Create New...