BryonR Posted April 20, 2009 Posted April 20, 2009 I'm having problems trying to get my combo box value to record. Its reading a text file for a list of values. expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.0.0 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <ButtonConstants.au3> #include <EditConstants.au3> $font = IniRead("c:\support.ini", "SiteInformation", "Font", "Times New Roman") $editcallgui = GUICreate("My GUI test", 400, 400) $APPLY = GUICtrlCreateButton("Apply", 1, 360, 129, 33, 0) $CANCEL = GUICtrlCreateButton("CANCEL", 270, 360, 129, 33, 0) $editcall_lbl_call = GUICtrlCreateLabel("Label1", 20, 150, 200, 50) GUICtrlSetFont(-1, 12, 400, 0, $font) GUICtrlSetColor(-1, 0x000080) $call_list = FileOpen("c:\list.txt",0) $angiocall = IniRead("C:\support.ini","CALL","DEPT","Default") $calledit_combo_call = GUICtrlCreateCombo ($call,200,150,200,120) If $call_list = -1 Then MsgBox(0, "Error","Call file not built.") Exit EndIf While 1 $line = FileReadLine($call_list) If @error =-1 Then ExitLoop $xc = StringFormat("%s",$line) GUICtrlSetData($calledit_combo_call, $xc) WEnd FileClose($call_list) $result_call = GUICtrlRead($calledit_combo_call, $xc) IniWrite ("i:\radsupport\radsupport.ini","DMICALL","DEPT",$result_call) GUISetState(@SW_SHOW) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $CANCEL ExitLoop Case $msg = $APPLY IniWrite ("C:\support.ini","CALL","DEPT",$result_call_angio) MsgBox(16, "Required", $result_call_angio) ExitLoop EndSelect WEnd
Valuater Posted April 20, 2009 Posted April 20, 2009 Maybe.. While 1 $line = FileReadLine($call_list) If @error =-1 Then ExitLoop $xc = StringFormat("%s",$line) $data &= $xc & "\" WEnd $data = StringTrimRight($data, 1) GUICtrlSetData($calledit_combo_call, $data) 8)
BryonR Posted April 21, 2009 Author Posted April 21, 2009 I tried the following code, however it only lists the first name in the list.txt file. #include <ButtonConstants.au3> #include <EditConstants.au3> $font = IniRead("c:\support.ini", "SiteInformation", "Font", "Times New Roman") $editcallgui = GUICreate("My GUI test", 400, 400) $APPLY = GUICtrlCreateButton("Apply", 1, 360, 129, 33, 0) $message = GUICtrlCreateButton("test", 1, 50, 129, 33, 0) $CANCEL = GUICtrlCreateButton("CANCEL", 270, 360, 129, 33, 0) $editcall_lbl_call = GUICtrlCreateLabel("dept1", 20, 150, 200, 50) GUICtrlSetFont(-1, 12, 400, 0, $font) GUICtrlSetColor(-1, 0x000080) $call_list = FileOpen("c:\list.txt", 0) $call = IniRead("c:\support.ini", "CALL", "dept1", "Default") $calledit_combo_call = GUICtrlCreateCombo($call, 200, 150, 200, 120) If $call_list = -1 Then MsgBox(0, "Error", "Call file not built.") Exit EndIf While 1 $line = FileReadLine($call_list) If @error = -1 Then ExitLoop $xc = StringFormat("%s", $line) $data = $xc & "\" WEnd $data = StringTrimRight($data, 1) GUICtrlSetData($calledit_combo_call, $data) FileClose($call_list) $result_call = GUICtrlRead($calledit_combo_call, $data) IniWrite("c:\support.ini", "CALL", "dept1", $result_call)
Valuater Posted April 21, 2009 Posted April 21, 2009 (edited) Sorry, I was unable to test, it should be $data &= $xc & "|" 8) EDIT.... This will not work $result_call = GUICtrlRead($calledit_combo_call, $data) IniWrite("c:\support.ini", "CALL", "dept1", $result_call) EDIT 2... This might do what you wanted $result_call = $call & "|" & $data IniWrite("c:\support.ini", "CALL", "dept1", $result_call) Edited April 21, 2009 by Valuater
BryonR Posted April 21, 2009 Author Posted April 21, 2009 How do I get the value of the combo box to wite to the ini?Sorry, I was unable to test, it should be$data &= $xc & "|"8)EDIT.... This will not work$result_call = GUICtrlRead($calledit_combo_call, $data)IniWrite("c:\support.ini", "CALL", "dept1", $result_call)EDIT 2... This might do what you wanted$result_call = $call & "|" & $dataIniWrite("c:\support.ini", "CALL", "dept1", $result_call)
Valuater Posted April 21, 2009 Posted April 21, 2009 This will get 1 selected item from the combobox $Combo_Read = GUICtrlRead($calledit_combo_call) IniWrite("c:\support.ini", "CALL", "dept1", $Combo_Read) 8)
BryonR Posted April 21, 2009 Author Posted April 21, 2009 I must be missing something I still can't get the item I've selected in the combo box to populate a var. It's always selecting the last item in the text file. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> $font = IniRead("c:\support.ini", "SiteInformation", "Font", "Times New Roman") $editcallgui = GUICreate("My GUI test", 400, 400) $APPLY = GUICtrlCreateButton("Apply", 1, 360, 129, 33, 0) $message = GUICtrlCreateButton("test", 1, 50, 129, 33, 0) $CANCEL = GUICtrlCreateButton("CANCEL", 270, 360, 129, 33, 0) $editcall_lbl_call = GUICtrlCreateLabel("dept1", 20, 150, 200, 50) GUICtrlSetFont(-1, 12, 400, 0, $font) GUICtrlSetColor(-1, 0x000080) $call_list = FileOpen("c:\list.txt", 0) $call = IniRead("c:\support.ini", "CALL", "dept1", "Default") $calledit_combo_call = GUICtrlCreateCombo($call, 200, 150, 200, 120) If $call_list = -1 Then MsgBox(0, "Error", "Call file not built.") Exit EndIf While 1 $line = FileReadLine($call_list) If @error = -1 Then ExitLoop $xc = StringFormat("%s", $line) $data = $xc & "\" GUICtrlSetData($calledit_combo_call, $data) WEnd $data = StringTrimRight($data, 1) FileClose($call_list) $result_call = GUICtrlRead($calledit_combo_call, $data) IniWrite("c:\support.ini", "CALL", "dept1", $result_call) GUISetState(@SW_SHOW) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $CANCEL ExitLoop Case $msg = $APPLY IniWrite("c:\support.ini", "CALL", "dept1", $result_call) ExitLoop Case $msg = $message MsgBox(16, "Required", $data) endSelect WEnd
Moderators Melba23 Posted April 21, 2009 Moderators Posted April 21, 2009 BryonR,You are only reading the combo immediately after it is created - hence $result_call always holds the default value.Try moving "$result_call = GUICtrlRead($calledit_combo_call, $data)" to within the "Case $msg = $APPLY" code so that you get the actual value when you press the button. The relevant section of your script should read like this:FileClose($call_list) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $CANCEL ExitLoop Case $msg = $APPLY $result_call = GUICtrlRead($calledit_combo_call, $data) IniWrite"c:\support.ini", "CALL", "dept1", $result_call) ExitLoopWith a test file I created in place of "c:\list.txt", this code gets the selected combo item into the ini file.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
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