oozma Posted April 10, 2009 Share Posted April 10, 2009 (edited) Could anyone give me some tips on how to create a 'save' button and have it add a user-given name to a drop down menu, and after they close the program they can open it and load from the drop down? Just the commands in Help to view if anything. I've created normal GUIs, but never saved something like this. Example: Field 1: 17 Field 2: 34 Click Save -> Named 'Test1' Close Program. Open Program -> Select 'Test1' from Dropdown -> Field 1&2 automatically filled in with 17,34. Thanks for any help you can give... Edited April 10, 2009 by oozma Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 10, 2009 Moderators Share Posted April 10, 2009 oozma, I am not altogether sure that I understand precisely what you are trying to do, but this does what I think you want. The first GUI has a combo with 2 entries: 17 and 34. Pressing 'Save' creates a small .lst file in the same folder as the script and then deletes the GUI (as if the script were closed). After a short pause a new GUI is created (as if the script were restarted). The combo now lists all .lst files in the folder. Choosing one of them loads the combo with the elements saved in the file. Selecting one of these elements opens a message box telling you which one you chose.expandcollapse popup#include <GUIConstantsEx.au3> #Include <GuiComboBox.au3> #Include <File.au3> $hGUI = GUICreate("Test 1", 500, 500) $hCombo = GUICtrlCreateCombo("", 10, 10, 200, 30) GUICtrlSetData(-1, "17|34") $hButton = GUICtrlCreateButton("Save", 10, 100, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton $aList1 = _GUICtrlComboBox_GetListArray($hCombo) _FileWriteFromArray(@ScriptDir & "\Test.lst", $aList1, 1) ExitLoop EndSwitch WEnd GUIDelete($hGUI) SplashTextOn("Waiting", "Next GUI along in a minute!") Sleep(2000) SplashOff() $aList3 = _FileListToArray(@ScriptDir & "\", "*.lst", 1) $sData = "" For $i = 1 To $aList3[0] $sData &= $aList3[$i] & "|" Next $hGUI = GUICreate("Test 2", 500, 500) $hCombo = GUICtrlCreateCombo("", 10, 10, 200, 30) GUICtrlSetData(-1, $sData) GUISetState() $fFile = True While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hCombo If $fFile = True Then $sFile = GUICtrlRead($hCombo) Global $aList2 _FileReadToArray(@ScriptDir & "\Saved.lst", $aList2) $sData = "" For $i = 1 To $aList2[0] $sData &= "|" & $aList2[$i] Next GUICtrlSetData($hCombo, $sData) $fFile = False Else MsgBox(0, "Result", "You chose" & @CRLF & @CRLF & GUICtrlRead($hCombo) ) Exit EndIf EndSwitch WEnd I hope this is something like what you wanted - if not it might give you some ideas, or help you explain a little more clearly what exactly you are trying to do. 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...
oozma Posted April 10, 2009 Author Share Posted April 10, 2009 Thanks, that's not exactly it but somewhat close. Sorry for not explaining better. Basically I want a standard GUI with input boxes for the user to type numbers or letters into. Something like... [Dropdown Box] [save Button] [Field 1:] [text here] [Field 2:] [text here] The first time using of course the drop down will be empty until something is saved. When I click save, I want another GUI to pop up asking the user for a name to save this as. I then want the GUI to remember what was typed in field 1 and 2, so that the next time the user runs the .exe the dropdown will be populate with, say "Please Select", and below that "Name1(what they named it the first time they hit save)" When you select Name1 from the drop down I want it to auto-populate the Field 1 and Field 2 boxes. Also hoping to save multiple names\values not just one I'm thinking a .ini file for saving, or like the list one you just posted. It's a really simple concept I don't think I'm explaining it well though sorry. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 10, 2009 Moderators Share Posted April 10, 2009 oozma,Well, you now have a bit of code and a logic flow to start with. ;-)You will need to use GUICtrlCreateInput for your fields and could use InputBox to get the filename to save.Have a go at it yourself - we are here if you run into problems.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...
oozma Posted April 10, 2009 Author Share Posted April 10, 2009 Thanks! Knowing which control to use for this will be helpful. I'll try it out. 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