KatoXY Posted March 31, 2011 Share Posted March 31, 2011 (edited) Hello,I want to write a script and I need use GUI command but I don’t know which I need in my script a list with all records from array or excel book. This list has to look like drop-down list with fonts in MS Word or their size.Could you show me?I looked again on AutoIt Help. There are many function with drop down list.I have to precise describe what I need and then I ask again. Edited March 31, 2011 by KatoXY Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 31, 2011 Moderators Share Posted March 31, 2011 KatoXY,The control is know as a Combo and you can produce one by using GUICtrlCreateCombo. If you want to fill it from an array, I would recommend doing something like this:#include <GUIConstantsEx.au3> ; Here is the array Global $aArray[5] = ["A", "B", "C", "D", "E"] ; And here we get the elements into a list $sList = "" For $i = 0 To UBound($aArray) - 1 $sList &= "|" & $aArray[$i] Next ; Create a GUI #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) ; Create the combo $hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20) ; And fill it GUICtrlSetData($hCombo, $sList) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndAll clear? Please ask if not. M23 Fr33b0w and SkysLastChance 2 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...
KatoXY Posted March 31, 2011 Author Share Posted March 31, 2011 Yes it's clear and great. I have 2d array and in ComboBox I want only 1st column, so I improve your script: ; Here is the array Global $aArray[5][2] = [["Andy", "Football"], ["Jon", "Swimming"], ["Jeremy", "Tennis"], ["Carol", "Basketball"], ["Vicky", "Hockey"]] ; And here we get the elements into a list $sList = "" For $i = 0 To UBound($aArray,1) -1 $sList &= "|" & $aArray[$i][0] Next ; Create a GUI #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) ; Create the combo $hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20) ; And fill it GUICtrlSetData($hCombo, $sList) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd [/code] Then I need to see label, list or small window, next to ComboBox, with data from 2nd column of my array and create dependency: when I chose in Combo i.e: Jeremy then I see Tennis in label, window. How to do it? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 31, 2011 Moderators Share Posted March 31, 2011 KatoXY, Perhaps like this? expandcollapse popup#include <GUIConstantsEx.au3> #include <Array.au3> ; Here is the array Global $aArray[5][2] = [["Andy", "Football"], ["Jon", "Swimming"], ["Jeremy", "Tennis"], ["Carol", "Basketball"], ["Vicky", "Hockey"]] ; And here we get the elements into a list $sList = "" For $i = 0 To UBound($aArray,1) -1 $sList &= "|" & $aArray[$i][0] Next ; Create a GUI #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) ; Create the combo $hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20) ; And fill it GUICtrlSetData($hCombo, $sList) ; Create label $hLabel = GUICtrlCreateLabel("", 220, 15, 200, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hCombo $sName = GUICtrlRead($hCombo) $iIndex = _ArraySearch($aArray, $sName) If Not @error Then GUICtrlSetData($hLabel, $aArray[$iIndex][1]) EndIf 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...
KatoXY Posted March 31, 2011 Author Share Posted March 31, 2011 Yeah, It's working very good. You are It helps me write my script. I will contact you If I have some trouble Thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 31, 2011 Moderators Share Posted March 31, 2011 atoXY,I will contact you If I have some troubleJust post in the forum - if I am not around someone else will help. 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...
Skysnake Posted May 26, 2014 Share Posted May 26, 2014 Thank you for this. I just posted on another thread about much the same thing. There is documentation on Combo boxes and documentation on Arrays, but I struggled (really!) to find an example of getting an array into a Combo box - and this one is just so smart - with lots of extra goodies, and the example is clear and simple Could this perhaps, please, be included in the standard documentation? Perhaps as an 'Advanced Example' in the GUICtrlCreateCombo help item? Thank you for your efforts. Skysnake Why is the snake in the sky? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 26, 2014 Moderators Share Posted May 26, 2014 Skysnake,All you need do to get an array into a combo is to convert the array to a string - and the _ArrayToString function will do that for you if you do not want write your own. But thanks for the compliments. 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...
heroeda Posted February 23, 2017 Share Posted February 23, 2017 (edited) On 3/31/2011 at 3:41 PM, Melba23 said: KatoXY, Perhaps like this? expandcollapse popup#include <GUIConstantsEx.au3> #include <Array.au3> ; Here is the array Global $aArray[5][2] = [["Andy", "Football"], ["Jon", "Swimming"], ["Jeremy", "Tennis"], ["Carol", "Basketball"], ["Vicky", "Hockey"]] ; And here we get the elements into a list $sList = "" For $i = 0 To UBound($aArray,1) -1 $sList &= "|" & $aArray[$i][0] Next ; Create a GUI #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) ; Create the combo $hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20) ; And fill it GUICtrlSetData($hCombo, $sList) ; Create label $hLabel = GUICtrlCreateLabel("", 220, 15, 200, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hCombo $sName = GUICtrlRead($hCombo) $iIndex = _ArraySearch($aArray, $sName) If Not @error Then GUICtrlSetData($hLabel, $aArray[$iIndex][1]) EndIf EndSwitch WEnd M23 How If need Global $aArray = "Combo.ini" [Data] [Andy Football] [Jon Swimming] [Jeremy Tennis] [Carol Basketball] [Vicky Hockey] Edited February 23, 2017 by heroeda Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 23, 2017 Moderators Share Posted February 23, 2017 heroeda, If you correctly format your ini file than IniReadSection will give you a 2D array to use: [Data] Andy=Football Jon=Swimming Jeremy=Tennis Carol=Basketball Vicky=Hockey #include <Array.au3> $aData = IniReadSection("Combo.ini", "Data") _ArrayDisplay($aData, "", Default, 8) M23 P.S. When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily. 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...
heroeda Posted February 27, 2017 Share Posted February 27, 2017 (edited) M23 why combo list not show Global $aArray[5][2] <------ this code delete or not. Edited February 27, 2017 by heroeda Link to comment Share on other sites More sharing options...
heroeda Posted March 9, 2017 Share Posted March 9, 2017 Solved and thanks Melba23 I change code: $aData = IniReadSection("Combo.ini","Data") $aArray = $aData ; List element $sList = "" For $i = 0 To UBound($aArray,1) -1 $sList &= "|" & $aArray[$i][0] Link to comment Share on other sites More sharing options...
spudw2k Posted March 22, 2017 Share Posted March 22, 2017 Just a quick comment/critique. Creating another Array variable and copying the $aData array to it is unnecessary/erroneous, unless you really need to retain the original array; but since you are just reading from it and not updating it I don't think that adds any value here. I would however suggest some error checking to ensure that the variable is in fact an array. Something to chew on: $aData = IniReadSection("Combo.ini","Data") If @error Or Not IsArray($aData) Then ;Error condition logic - Notify user, exit function, what-have-you EndIf ; List element $sList = "" For $i = 0 To UBound($aData,1) -1 $sList &= "|" & $aData[$i][0] Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
antonioj84 Posted April 10, 2017 Share Posted April 10, 2017 (edited) can someone help me with this, I have 1 drop list base on selection radio1 or radio2 it will display a different content to select on the list #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 255, 253, 192, 124) $Radio1 = GUICtrlCreateRadio("Radio1", 40, 48, 65, 17) ; IF RADIO1 SELECTED LIST0 IS SELECTED $Radio2 = GUICtrlCreateRadio("Radio2", 128, 48, 65, 17) ;IF RADIO2 SELECTED LIST1 IS SELECTED $Group1 = GUICtrlCreateGroup("POS", 24, 24, 177, 49) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $slist[1] ;index to keep list 0,1 Global $aArray0[5] = [1,2,3,4,5] ;VALUE LIST0 Global $aArray1[5] = [6,7,8,9,10] ;VALUE LIST1 ; fill both arrary0, array1 with the content for list 0 and list 1 respectively $sList[0] = "" ;~$slist[1] = "" For $i = 0 To UBound($aArray0) - 1 $sList[0] &= "|" & $aArray0[$i] ;~For $j = 0 To UBound($aArray1) - 1 ;~ $sList[1] &= "|" & $aArray1[$j] ;~Next Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited April 10, 2017 by antonioj84 ok Link to comment Share on other sites More sharing options...
spudw2k Posted April 10, 2017 Share Posted April 10, 2017 (edited) What do you need help with? I didn't see a clear question above...so I'll guess. Displaying the list? How do you want it displayed? (ArrayDisplay, Listview, ConsoleWrite, etc.) Assigning the desired list to $sList? Other? Edited April 10, 2017 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
antonioj84 Posted April 10, 2017 Share Posted April 10, 2017 Hi spudw2k, If radio1 or radio2 is selected the dropdown list content for selecting will be different. Radio0 will list on the dropdown 1,2,3,4,5 Radio1 will list on the dropdown 5,6,7,8,910 Note bien, there is only on dropdown list only the content for selection will be different base on the checked option radio0 or radio1 Link to comment Share on other sites More sharing options...
spudw2k Posted April 10, 2017 Share Posted April 10, 2017 Ok, should be easy enough. Do you have more code with the dropdown list control already in place? Is it a combobox? Also, just a thought....will your arrays be changing during runtime, or will they always be defined, hardcoded in the script? You might as well just have them be strings to begin with. That way you don't have to do any additional processing/formatting before applying the data to the dropdown. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
antonioj84 Posted April 10, 2017 Share Posted April 10, 2017 Kool, the array values are hard-coded and won't change, sure i can have them as a string. I need assistance in filling the 2 $list[1] from the $array0 and $array1 Link to comment Share on other sites More sharing options...
spudw2k Posted April 10, 2017 Share Posted April 10, 2017 (edited) Well, if you use strings instead, you don't need to bother with populating the $slist[1]. Global $slist[1] ;index to keep list 0,1 Global $aArray0[5] = [1,2,3,4,5] ;VALUE LIST0 Global $aArray1[5] = [6,7,8,9,10] ;VALUE LIST1 ;would become Global $sList1 = "|1|2|3|4|5" Global $sList2 = "|6|7|8|9|10" Also, an array with only 1 index ($sList[1]) doesn't add any value that I can see that you can't accomplish with a string, or am I missing something? If you really want to do it using arrays, I won't stop you. Just trying to make things simpler for ya. You were on your way there with your for loop. Edited April 10, 2017 by spudw2k added preceding GUISeparatorChar to list strings to ease updating combo antonioj84 1 Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
antonioj84 Posted April 11, 2017 Share Posted April 11, 2017 $sList1="" If GUICtrlRead($Box1) = $GUI_CHECKED Then $sList1 = "|1|2|3|4|5" EndIf $sList1="" If GUICtrlRead($Box2) = $GUI_CHECKED Then $sList1 = "|6|7|8|9|10" EndIf this solution will work for sure, however I was shooting for my solution 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