Jump to content

ComboBox: Retrieve Selection to establish a Case

Recommended Posts


got to start a new topic for this problem, because it would make no sense to drift off-topic in another thread.

not really sure if this is technically a GUI problem or a scripting problem, so I will just give it a try here. 

i have a small snippet from a script that demonstrates my problem:

Local $drivelist = DriveGetDrive("ALL")


$combo=GUICtrlCreateCombo("Select Drive...",50,20)
$select=GUICtrlCreateButton("SELECT", 20,150,120,30)
$cancel=GUICtrlCreateButton("CANCEL", 160,150,120,30)
For $i=1 To Ubound($drivelist)-1


Until $msg=-3

here my local computer drives are selected and stored in an array. In the _ArrayDisplay() I can see the names of all my local drives (irrespective of what type they are). that data is then used to fill the combobox with the returned value that is stored in the array. 

on my computer (this is just an example): I have 15 partitions on my harddrive and so there will be at least 15 drives and additional ones for disk drives, etc.

I understand that I can select with "_GUICtrlComboBox_GetCurSel()" a specific one and then probably use the data within that to do something else with it.

I know that there are 15,16,17 or however many drives, so i can just write 15,16,17 cases in order to do something but that is just not good enough!

a different computer might only have 3 drives, or 10 drives, etc.

that means i need some kind of universal solution that grabs the selection (The selected text from within the ComboBox) from the ComboBox and makes a case out of that, or in other words one case with an excangeable variable (the selected text from within the ComboBox) so that for every selction something can be done without knowing how many cases there are.

if "c:" is selected then do this and this ; if "h:" is selected then do this and that, etc.

now the problem is that i do not know how many variables must be created on different computers, so i do not know how many cases must be made.


one important thing: this snippet is an example  of what must be done and is just the most simple way to demonstrate that on every computer the result might be different. my problem has not got anything to do with harddrives but rather more with getting the selected text and using that data somewhere else to do other tasks. just take it for granted that the ComboBox would be different on every computer and therefor a universal solution is what i have in mind.


problem summary:

a randomly created and generated Array is transfered into a ComboBox and every selection should copy the selected text that is in the ComboBox and store it in a value that can be called/used in a "Case" to then do something else, like display a MessageBox or what ever. The amount of possible selections is unknown. The Text in the selction is unknown. All values are unknown but must be used somewhere else. how can this be done?


I am greatful for any help.


kind regards

Link to post
Share on other sites
  • Moderators


Does not seem too difficult:

#include <GUIConstantsEx.au3>
#include <Array.au3>

Local $drivelist = DriveGetDrive("ALL")


$combo=GUICtrlCreateCombo("Select Drive...",50,20)
$select=GUICtrlCreateButton("SELECT", 20,150,120,30)
$cancel=GUICtrlCreateButton("CANCEL", 160,150,120,30)
For $i=1 To Ubound($drivelist)-1


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $cancel
        Case $select
            $sChosen = GUICtrlRead($combo)
            ConsoleWrite($sChosen & @CRLF)


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:


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 post
Share on other sites

that is just to damn simple. thanks. somehow i was expecting something very dificult but that is so simple that i did not even think of it at all. 

in germany there is a figure of speech for something like that, i will translate it into english:

"sometimes you do not see the forest due to the amount of trees (infront of you)"

damn, that is just to easy. I do not know why i thought that it would be nearly impossible to grab the selection from an unknown amount of variables.

thanks that will help me to get further in my script.


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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...