Jump to content

Combobox with variable value


ScriptNoob
 Share

Recommended Posts

I am just trying to create a dropdown that has options inside of it but for each of these options have different values.

For example the dropdown would say "Orlando" but the value would be orlando.server1.com and I would want this stored in a variable.

I know how to create the dropdown and variables but im not sure how to assign the alternate value to the combobox elements.

Any help is appreciated.

Link to comment
Share on other sites

  • Moderators

ScriptNoob,

The simplest way would be to get a value in the combo box, then use GUICtrlRead in a Select Case. Something like this:

#include <GUIConstantsEx.au3>

GUICreate("Test",200,300)
GUICtrlCreateLabel("Please select your nearest office",3,8)

$n1=GUICtrlCreateList ("", 45,35,100,220 )
GUICtrlSetData(-1,"Basingstoke|Sunderland|Aberdeen", "Aberdeen")

$n2=GUICtrlCreateButton ("Start",50, 260, 80, 30)
GUICtrlSetState(-1,$GUI_FOCUS); the focus is on this button

GUISetState()

; Get location
While 1
    
    $msg = GUIGetMsg()
        
    If $msg = $n2 Then 
        Select
            case GUICtrlRead($n1) = "Basingstoke"
                $Server = "\\basiserver\Software"
            case GUICtrlRead($n1) = "Sunderland"
                $Server = "\\sundserver\Software"
            case GUICtrlRead($n1) = "Aberdeen"
                $Server = "\\aberserver\Software"
            
        EndSelect
        ExitLoop
    ElseIf $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
WEnd

ConsoleWrite($Server & "\Install\Setup.exe" & @CRLF)

Hope this helps,

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

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