mohammadezazi Posted July 1, 2013 Share Posted July 1, 2013 (edited) Hi This is my code. I want to get the key value from .ini file. Thanks for help. And the ini file is: [Combo] 1=combotext1 2=combotext2 3=combotext3 4=combotext4 5=combotext5 for example : I want to get the number 3 , when i select the combobox3 text in combobox. #include <Constants.au3> #include <GuiComboBox.au3> #include <ComboConstants.au3> Global $ini_saved_file = @ScriptDir & "\config.ini" Global $hCombo ;-------------------------------------------------------------------------------------------------------------Create GUI $hgui = GUICreate("MyTest", 400, 296) ;------------------------------------------------------------------------------------------create ComboBox $cCombo = GUICtrlCreateCombo('', 2, 180, 396, 296) _ReadComboOptions_FromINI() ;------------------------------------------------------------------------------------------------------------------------------------------------------------- GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE GUIDelete($hgui) Exit EndSwitch WEnd Func _ReadComboOptions_FromINI() $aIniRead = IniReadSection($ini_saved_file, "Combo") If Not @Error Then $sCombo_List = "" For $i = 1 To $aIniRead[0][0] $sCombo_List &= "|" & $aIniRead[$i][1] Next GUICtrlSetData($cCombo, $sCombo_List) EndIf EndFunc Edited July 1, 2013 by mohammadezazi Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 1, 2013 Moderators Share Posted July 1, 2013 mohammadezazi,You already have the ini array, so use it: expandcollapse popup#include <GUIConstantsEx.au3> Global $ini_saved_file = @ScriptDir & "\config.ini" Global $aIniRead = IniReadSection($ini_saved_file, "Combo") If @error Then MsgBox(0,"Ooops", "Error") Exit EndIf $hGUI = GUICreate("MyTest", 400, 296) $cCombo = GUICtrlCreateCombo('', 2, 180, 396, 296) _ReadComboOptions_FromINI() GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE GUIDelete($hGUI) Exit Case $cCombo For $i = 1 To $aIniRead[0][0] If $aIniRead[$i][1] == GUICtrlRead($cCombo) Then MsgBox(0, "Hi", $i) ExitLoop EndIf Next EndSwitch WEnd Func _ReadComboOptions_FromINI() $sCombo_List = "" For $i = 1 To $aIniRead[0][0] $sCombo_List &= "|" & $aIniRead[$i][1] Next GUICtrlSetData($cCombo, $sCombo_List) EndFunc ;==>_ReadComboOptions_FromINIAll clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
mohammadezazi Posted July 1, 2013 Author Share Posted July 1, 2013 (edited) Tnx I love you It works fine Edited July 1, 2013 by mohammadezazi 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