Jump to content

Recommended Posts

Posted

Hello,

How to read selected value of combo box control using autoIT?

I have below script.

GUICreate("ComboBox",225,100)

$controlID = GUICtrlCreateCombo( "---",0 ,0 ,100,10) ; create first item

GUICtrlSetData(3, " ITEM 1| ITEM2| ITEM3")

Now i would like to get selected value when it is selected by user.

Please help.

Thanks.

Posted

Use GUICtrlRead

$sSelected = GUICtrlRead($controlID)

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.
Posted

#include <GUIConstantsEx.au3>

Global $hGUI, $ComboBox

$hGUI = GUICreate('ComboBox', 200, 200)
$ComboBox = GUICtrlCreateCombo('---', 0, 0, 200, 200)
GUICtrlSetData($ComboBox, 'ITEM1|ITEM2|ITEM3')

GUISetState()
While True
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
            
        Case $ComboBox
            ConsoleWrite(GUICtrlRead($ComboBox) & @CRLF)
    EndSwitch
WEnd

Posted

Thanks, it worked....

#include <GUIConstantsEx.au3>

Global $hGUI, $ComboBox

$hGUI = GUICreate('ComboBox', 200, 200)
$ComboBox = GUICtrlCreateCombo('---', 0, 0, 200, 200)
GUICtrlSetData($ComboBox, 'ITEM1|ITEM2|ITEM3')

GUISetState()
While True
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
            
        Case $ComboBox
            ConsoleWrite(GUICtrlRead($ComboBox) & @CRLF)
    EndSwitch
WEnd

Posted

Use _GUICtrlComboBox_FindStringExact() to get the index of the selected item:

#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>

Global $hGUI, $ComboBox

$hGUI = GUICreate('ComboBox', 200, 200)
$ComboBox = GUICtrlCreateCombo('---', 0, 0, 200, 200)
GUICtrlSetData($ComboBox, 'ITEM1|ITEM2|ITEM3')

GUISetState()
While True
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit

        Case $ComboBox
            ConsoleWrite(GUICtrlRead($ComboBox) & _
        '  Index: ' & _GUICtrlComboBox_FindStringExact($ComboBox, GUICtrlRead($ComboBox)) & @CRLF)
    EndSwitch
WEnd

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...