Damein Posted October 24, 2010 Share Posted October 24, 2010 So, I have a ComboBox and I have 3 items in it. I want to be able to get the number I have selected, not the name. I know I can get the selection via: ControlGetText("Name", "", $ComboBox) But in order for me to accomplish something I need to get the number. IE: ComboBox = Red|Blue|Green And instead of getting: Red I want to get 1 and etc. Thanks Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
MvGulik Posted October 24, 2010 Share Posted October 24, 2010 If you still have the original array data available you could try something like this. (Native AutoIt, untested after rewriting it a bit.) Func Get_ComboSelectedId($hCombo, $asDataLines) Local $sSelectedText = GUICtrlRead($hCombo) Local $iEntryId = -1 ;; zero based. For $i = 0 To UBound($asDataLines, 1) - 1 If Not ($asDataLines[$i] == $sSelectedText) Then ContinueLoop ;; case sensitve. $iEntryId = $i ExitLoop Next If $iEntryId < 0 Then SetError(1) Return $iEntryId EndFunc Or take a look at "_GUICtrlComboBox_GetCurSel" -> GuiComboBox UDF. Note: In general is best to only use GuiComboBox UDF functions on Combobox's that are also created with GuiComboBox UDF. "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 24, 2010 Moderators Share Posted October 24, 2010 (edited) Or take a look at "_GUICtrlComboBox_GetCurSel" -> GuiComboBox UDF. Or ControlCommand("Window Handle or Title", "Text If Any", "ControlID/ClassNameNN/Handle", "GetCurrentSelection", "")(If it's a standard window of course) Edit: I didn't notice you wanted the actual drop down index number. It might be better to use the _GUI* UDFs indeed. Edited October 24, 2010 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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