juk Posted June 30, 2005 Posted June 30, 2005 Couldn't find an answer from previous topics to how can I get the elements from a combobox into an array? If someone has a valid function or something, it would be very helpful! -juk
GaryFrost Posted June 30, 2005 Posted June 30, 2005 Beta version Retrieve a string from the list of a combo box. #Include <GuiCombo.au3> _GUICtrlComboGetLBText($h_combobox, $i_index, ByRef $s_text) SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
juk Posted July 1, 2005 Author Posted July 1, 2005 Beta versionRetrieve a string from the list of a combo box.#Include <GuiCombo.au3>_GUICtrlComboGetLBText($h_combobox, $i_index, ByRef $s_text)<{POST_SNAPBACK}>I didn't even know about the beta versions, thanks!Now I've got the 3.1.1.55 beta version, but it's not working for me:#include <GuiConstants.au3> #include <GuiCombo.au3> opt("WinTitleMatchMode",2) If Not WinActive("My Computer","") Then WinActivate("My Computer","") WinWaitActive("My Computer","") $i=0 Global $s_text While 1 $i_count = _GUICtrlComboGetLBText(41477, $i, $s_text) if $i_count == -1 Then ExitLoop EndIf MsgBox(0,"","length: " & $i_count&", text: " & $s_text) $i=$i+1 WEndThere I've tried to get the elements from the explorer's combobox (control id 41447) and show them in a msgbox, but this just doesn't work! Msgbox shows zero (0) for both $i_count and $s_text each time and all the time. The variable $i works just fine.I've tried to get the insides of comboboxes from different windows aswell, but never succeeded. Has anyone got a working solution to this?-juk
Valuater Posted July 1, 2005 Posted July 1, 2005 1st $i_count = _GUICtrlComboGetLBText(41477, $i, $s_text and combobox (control id 41447) which is correct???? also, this is not my specialty, but ... you are trying to read a window (my Computer)... not an actual combo box and quote" how can I get the elements from a combobox into an array?" However, you appear to be working with a $string not an $array[0].. there is a major difference lastly nice try 8)
GaryFrost Posted July 1, 2005 Posted July 1, 2005 (edited) The UDFs only work with the GUI ComboBox, didn't write them for the system wide combobox's, if you need to access a ComboBox outside of the AutoIt GUI you'll need to learn about the DllCall function, also you'll have to research the ComboBox control, SendMessage at MSDN. Here's an example of getting all the items from a AutoIt GUI ComboBox and putting them into an array. expandcollapse popup#include <GuiConstants.au3> #include <GuiCombo.au3> #include <Array.au3> opt('MustDeclareVars', 1) Dim $Combo, $ret, $Btn_Exit, $Status, $msg, $Btn_Get, $Btn_Show, $a_ComboList, $i, $i_count, $s_text GUICreate("ComboBox Get Count", 392, 254) $Combo = GUICtrlCreateCombo("", 70, 10, 270, 100, $CBS_SIMPLE) $ret = _GUICtrlComboAddDir ($Combo, "drives") $Btn_Get = GUICtrlCreateButton("Get Text", 150, 120, 90, 30) $Btn_Show = GUICtrlCreateButton("Show Array", 150, 160, 90, 30) $Btn_Exit = GUICtrlCreateButton("Exit", 150, 200, 90, 30) $Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER)) GUICtrlSetData($Status, "Items in ComboBox: " & _GUICtrlComboGetCount ($Combo)) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit ExitLoop Case $msg = $Btn_Get For $i = 0 To _GUICtrlComboGetCount ($Combo) - 1 $i_count = _GUICtrlComboGetLBText ($Combo, $i, $s_text) If IsArray($a_ComboList) Then ReDim $a_ComboList[UBound($a_ComboList) + 1] Else Dim $a_ComboList[1] EndIf $a_ComboList[UBound($a_ComboList) - 1] = $s_text Next Case $msg = $Btn_Show _ArrayDisplay($a_ComboList, "Combobox Items") EndSelect WEnd Exit Edited July 1, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
juk Posted July 1, 2005 Author Posted July 1, 2005 1st $i_count = _GUICtrlComboGetLBText(41477, $i, $s_textand combobox (control id 41447) which is correct????Ok, I made a typo in the text, but it was right in the code. also, this is not my specialty, but ...you are trying to read a window (my Computer)... not an actual combo boxI'm trying to read a combobox in a window (they usually are inside windows, right?) which happens to be explorer (My Computer). I tried it with various different softwares' windows' comboboxes also (acrobat reader, ms paint, you name it). All failed.andquote" how can I get the elements from a combobox into an array?"However, you appear to be working with a $string not an $array[0].. there is a major difference<{POST_SNAPBACK}>That was my original idea, but mr. gafrost presented a similiar solution (combobox to string) so I started working with that.-juk
juk Posted July 1, 2005 Author Posted July 1, 2005 The UDFs only work with the GUI ComboBox, didn't write them for the system wide combobox's, if you need to access a ComboBox outside of the AutoIt GUIyou'll need to learn about the DllCall function, also you'll have to research the ComboBox control, SendMessage at MSDN.<{POST_SNAPBACK}>Ah, so that's it! I'm still new at this so couldn't figure it out. Thanks!I found some dllcall, from previous posts, that counted elements in a combo, but am still looking for one that gives them in an array. Tried to search MSDN also, but it seemed like an ocean of useless information (for me). Maybe I just gotta look harder...-juk
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