Jump to content
Sign in to follow this  
Fantasy

Save Information ?

Recommended Posts

Fantasy

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

Share this post


Link to post
Share on other sites
MrChiliCheese

When the GUI with the options opens, u could read and save the data with IniWrite for example...

Share this post


Link to post
Share on other sites
Fantasy

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:

Share this post


Link to post
Share on other sites
Valuater

$Info = GuiCtrlRead($Control)

IniWrite("file.ini","settings","This control", $Info)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Melba23

Fantasy,

This should give you a good handle on how to go about it:

#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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Fantasy

Thanks alot melba23 ! ^_^

That was just what I needed (:

Share this post


Link to post
Share on other sites
Melba23

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):

#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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Fantasy

Thanks a lot for your help, I really appreciate it. Sorry about the pm :\

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×