Fantasy Posted April 20, 2009 Share Posted April 20, 2009 Hey people.. I've played around with AutoIt for a long time, and learned it all by myself.. I just need help with one thing now.. I have this GUI, with buttons.. One of them says options.. Anyhow, what I need is, that when you press that button, it should open up a new gui where you can set some preferences (like sleep time). It should also save and store this information, so the next time you open it up, it shouldn't be neccesary to type in again.. So basically I need my program to read from the file, that the options-UI saved. Can someone make a little tiny example that shows this? So in short GUI That opens new gui with some information that can be stored and used again. Hope you can help me out here.. (: Thanks in advance Link to comment Share on other sites More sharing options...
MrChiliCheese Posted April 20, 2009 Share Posted April 20, 2009 When the GUI with the options opens, u could read and save the data with IniWrite for example... Link to comment Share on other sites More sharing options...
Fantasy Posted April 20, 2009 Author Share Posted April 20, 2009 When the GUI with the options opens, u could read and save the data with IniWrite for example...Could you please be so kind to make an example? s: Link to comment Share on other sites More sharing options...
Valuater Posted April 20, 2009 Share Posted April 20, 2009 $Info = GuiCtrlRead($Control) IniWrite("file.ini","settings","This control", $Info) 8) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 20, 2009 Moderators Share Posted April 20, 2009 Fantasy, This should give you a good handle on how to go about it:expandcollapse popup#include <GUIConstantsEx.au3> $sIniFile = @ScriptDir & "\test.ini" $hGUI = GUICreate("Test", 500, 500) $hButton = GUICtrlCreateButton("Options", 10, 10, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton _Options() EndSwitch WEnd Func _Options() $sValue = IniRead($sIniFile, "Section", "Option", "Empty") $hOptions = GUICreate("Options", 200, 200) GUICtrlCreateLabel("Enter a value", 10, 10, 100, 20) $hInput = GUICtrlCreateInput($sValue, 10, 30, 100, 20) $hSave = GUICtrlCreateButton("Save", 10, 90, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $hSave IniWrite($sIniFile, "Section", "Option", GUICtrlRead($hInput)) ContinueCase Case $GUI_EVENT_CLOSE GUIDelete($hOptions) Return EndSwitch WEnd EndFunc 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...
Fantasy Posted April 21, 2009 Author Share Posted April 21, 2009 Thanks alot melba23 ! That was just what I needed (: Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 21, 2009 Moderators Share Posted April 21, 2009 Fantasy, Please do not PM questions - it is considered extremely rude. If you post in the thread then the whole community can benefit - which is why we are here, after all. :-) Hey M23.. Your file helped me, A LOT ! It's just that when I want to do it myself, it goes wrong .. First of all, mine needs 3 different settings, which the program has to read from later on.' I just created more Inputs and more Case 's .. But all it does it create a .ini file, that contains text, but not what you typed in? here's the two GUI's I need to work together. Can you tell whats wrong?Now we have got that out of the way, there were a number of things which prevented the scripts working: 1- You had the same variable name ($Settings) in both. That meant you could only get the 'Settings' button to work the first time - after that the ControlID value was changed to that of the Settings GUI and you could not get GUIGetMsg() to pick it up as you had already deleted it! 2 - Read the Help file carefully about IniRead and IniWrite - your parameters were all over the place! Study the example below. 3 - When you IniWrite, you need to read the Input controls by using their ControlIDs - you were using the variable that was placed in them when they were created. This should work for you (at least as far as the setting goes):expandcollapse popup#include <GUIConstants.au3> $Florensia_Bot__By_Fantasy = GUICreate("Florensia Bot by Fantasy ", 257, 399, 316, 175) GUISetBkColor(0xA6CAF0) $Bot_Controls = GUICtrlCreateGroup("Control Panel for Bot", 24, 8, 209, 177) $Start_Bot = GUICtrlCreateButton("Start Florensia Bot", 32, 24, 193, 33, 0) GUICtrlSetTip(-1, "Start the bot") GUICtrlSetCursor(-1, 0) $Stop_Bot = GUICtrlCreateButton("Stop Florensia Bot", 32, 64, 193, 33, 0) GUICtrlSetTip(-1, "Exit and close down the bot") GUICtrlSetCursor(-1, 0) $Update_Bot = GUICtrlCreateButton("Update Florensia Bot", 32, 104, 193, 33, 0) GUICtrlSetTip(-1, "Click here to get the latest version of the bot") GUICtrlSetCursor(-1, 0) $Settings = GUICtrlCreateButton("Settings", 32, 144, 193, 33, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateInput("Write name here to become badass :D", 32, 200, 193, 21) GUICtrlSetCursor(-1, 5) $Group1 = GUICtrlCreateGroup("Credits", 48, 280, 161, 81) $Label1 = GUICtrlCreateLabel("Fantasy", 104, 296, 41, 17) $Label3 = GUICtrlCreateLabel("www.Forum.CheatEngine.org", 56, 320, 142, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $HelpAbout = GUICtrlCreateButton("Help && About", 56, 232, 153, 33, 0) GUICtrlSetTip(-1, "If you need help using the bot or just want to know more, click here") GUICtrlSetCursor(-1, 0) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Settings Settings() EndSwitch WEnd Func Settings() $sIniFile = @ScriptDir & "\Settings.ini" $CombatTimeValue = IniRead($sIniFile, "Florensia Bot Settings", "Combat Time", "Empty") $HealthValue = IniRead($sIniFile, "X", "Health", "Empty") $ManaValue = IniRead($sIniFile, "Y", "Mana", "Empty") $Settings_GUI = GUICreate("Settings - Florensia Bot", 242, 172, 296, 195) GUISetBkColor(0xA6CAF0) $CombatTime = GUICtrlCreateInput($CombatTimeValue, 32, 24, 49, 21) $Label1 = GUICtrlCreateLabel("Combat Time", 96, 24, 66, 17) $Health = GUICtrlCreateInput($HealthValue, 32, 56, 49, 21) $Label2 = GUICtrlCreateLabel("Health", 96, 56, 59, 17) $Mana = GUICtrlCreateInput($ManaValue, 32, 88, 49, 21) $Label3 = GUICtrlCreateLabel("Mana", 96, 88, 63, 17) $Button1 = GUICtrlCreateButton("Save Settings", 56, 128, 113, 33, 0) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $Button1 IniWrite($sIniFile, "Florensia Bot Settings", "Combat Time", GUICtrlRead($CombatTime)) IniWrite($sIniFile, "X", "Health", GUICtrlRead($Health)) IniWrite($sIniFile, "Y", "Mana", GUICtrlRead($Mana)) ContinueCase Case $GUI_EVENT_CLOSE GUIDelete($Settings_GUI) Return EndSwitch WEnd EndFunc ;==>Settings If anything is unclear - ask here! 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...
Fantasy Posted April 21, 2009 Author Share Posted April 21, 2009 Thanks a lot for your help, I really appreciate it. Sorry about the pm :\ 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