Jump to content
Sign in to follow this  

reading text from the input of a comboboxEx

Recommended Posts


Reading from the edit control of an comboboxEx with style $CBS_DROPDOWN $WS_VSCROLL


I always get "".

But using the style $CBS_SIMPLE it works fine. I've added a code example to demostate the behavior (from the autoit documentation with some modifications):

#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
#include <GuiConstantsEx.au3>

Opt('MustDeclareVars', 1)

$Debug_CB = False ; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work


Func _Main()
    Local $hGUI, $hImage, $hCombo
    ; Create GUI
    $hGUI = GUICreate("ComboBoxEx Get Edit Text", 400, 300)
    $hCombo = _GUICtrlComboBoxEx_Create ($hGUI, "", 2, 2, 394, 100); $CBS_SIMPLE removed!!! Gafrost knew it!

    $hImage = _GUIImageList_Create (16, 16, 5, 3)
    _GUIImageList_AddIcon ($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon ($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon ($hImage, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon ($hImage, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon ($hImage, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon ($hImage, @SystemDir & "\shell32.dll", 146)
    _GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($hCombo, 0xFF0000, 16, 16))
    _GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($hCombo, 0x00FF00, 16, 16))
    _GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($hCombo, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList ($hCombo, $hImage)

    For $x = 0 To 8
        _GUICtrlComboBoxEx_AddString ($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)), $x, $x)
    ; Set Edit Text
    _GUICtrlComboBoxEx_SetEditText ($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1)))
    ; Get Edit Text
    MsgBox(4160, "Information", "Edit Text: " & _GUICtrlComboBoxEx_GetEditText ($hCombo))
    ;Get Edit Text
    MsgBox(4160, "Information", "Edit Text: " & _GUICtrlComboBoxEx_GetEditText ($hCombo))
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>_Main

The same function works fine for normal combos _GUICtrlComboBox_GetEditText($hCombo).

Does anybody know a workaround or some other function I can call to get the text of the edit?

Many thanks in advance,


Share this post

Link to post
Share on other sites


It might be a little bit late, but I got the issue yesterday and solved it by "simply" adding this:

_GUICtrlComboBoxEx_BeginUpdate ($hCombo)

_GUICtrlComboBoxEx_EndUpdate ($hCombo)


_GUICtrlComboBoxEx_GetItemText ($hCombo, _GUICtrlComboBoxEx_GetCurSel($hCombo), $DestDim)

By checking with a MsgBox(0,"",$DestDim)

I can read the correct value.

Hope it will help...

Share this post

Link to post
Share on other sites

If $CBS_DROPDOWN style is used, the edit control has a separate handle from the combo itself. That's why you have _GUICtrlComboBoxEx_GetEditControl():

While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
            Case $idButton
                $hEdit = _GUICtrlComboBoxEx_GetEditControl($hCombo)
                $sText = ControlGetText($hGUI, "", $hEdit)
                MsgBox(4160, "Information", "Edit Text: " & $sText)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post

Link to post
Share on other sites

... even a bit late, your answers are (specially) wellcome!!!

I'll try it out.


Share this post

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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.