Kash Posted August 13, 2009 Posted August 13, 2009 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.
Yoriz Posted August 13, 2009 Posted August 13, 2009 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.
Authenticity Posted August 13, 2009 Posted August 13, 2009 #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
Kash Posted August 13, 2009 Author Posted August 13, 2009 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
ogeiz Posted August 15, 2009 Posted August 15, 2009 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
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