roeselpi Posted May 6, 2019 Share Posted May 6, 2019 hi, 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") _ArrayDisplay($drivelist) $hwnd=GUICreate("DriveSpace...",300,200) $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 GUICtrlSetData($combo,$drivelist[$i]) Next GUISetState() Do $msg=GUIGetMsg() 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 comment Share on other sites More sharing options...
Moderators Melba23 Posted May 6, 2019 Moderators Share Posted May 6, 2019 roeselpi, Does not seem too difficult: #include <GUIConstantsEx.au3> #include <Array.au3> Local $drivelist = DriveGetDrive("ALL") _ArrayDisplay($drivelist) $hwnd=GUICreate("DriveSpace...",300,200) $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 GUICtrlSetData($combo,$drivelist[$i]) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $cancel Exit Case $select $sChosen = GUICtrlRead($combo) ConsoleWrite($sChosen & @CRLF) EndSwitch WEnd M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
roeselpi Posted May 8, 2019 Author Share Posted May 8, 2019 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. roselpi Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now