Sign in to follow this  
Followers 0
oozma

GUI to INI

10 posts in this topic

Hi,

I'm trying to write this GUI to an INI when I click the OK button. Right now it doesn't do anything.. the GUI doesn't even close when I click OK.

What gives? I've read through all the help files on iniwrite and don't see anything wrong :P

Thanks for any help anyone can offer.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

;;LABELS
$MTrainer = GUICreate("mt", 210, 265, 269, 218)
$MM = GUICtrlCreateLabel("Mm:", 16, 56, 70, 17)
$HS = GUICtrlCreateLabel("hs:", 32, 80, 50, 17)
$R = GUICtrlCreateLabel("r:", 56, 104, 29, 17)
$Ok = GUICtrlCreateButton("Ok", 56, 232, 105, 25, 0)
$Max = GUICtrlCreateLabel("m:", 8, 200, 135, 17)
$Hotkey = GUICtrlCreateLabel("hk", 88, 32, 38, 17)
$S = GUICtrlCreateGroup("ss", 8, 8, 161, 169)
;;INPUTS
$Mi = GUICtrlCreateInput("", 96, 48, 20, 21)
GUICtrlSetLimit(-1, 2)
$He = GUICtrlCreateInput("", 96, 72, 20, 21)
GUICtrlSetLimit(-1, 2)
$Re = GUICtrlCreateInput("", 96, 96, 20, 21)
GUICtrlSetLimit(-1, 2)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Ma = GUICtrlCreateInput("", 144, 192, 40, 21)
GUICtrlSetLimit(-1, 3)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = $GUI_EVENT_CLOSE
        Exit
    Case $Ok
        IniWrite("\config.ini", "Variables", "$hs", GuiCtrlRead($he))
        IniWrite("\config.ini", "Variables", "$mi", GuiCtrlRead($mi))
        IniWrite("\config.ini", "Variables", "$r", GuiCtrlRead($re))
        IniWrite("\config.ini", "Variables", "$mt", GuiCtrlRead($ma))
    EndSelect
WEnd

Share this post


Link to post
Share on other sites



Try this:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

;;LABELS
$MTrainer = GUICreate("mt", 210, 265, 269, 218)
$MM = GUICtrlCreateLabel("Mm:", 16, 56, 70, 17)
$HS = GUICtrlCreateLabel("hs:", 32, 80, 50, 17)
$R = GUICtrlCreateLabel("r:", 56, 104, 29, 17)
$Ok = GUICtrlCreateButton("Ok", 56, 232, 105, 25, 0)
$Max = GUICtrlCreateLabel("m:", 8, 200, 135, 17)
$Hotkey = GUICtrlCreateLabel("hk", 88, 32, 38, 17)
$S = GUICtrlCreateGroup("ss", 8, 8, 161, 169)
;;INPUTS
$Mi = GUICtrlCreateInput("", 96, 48, 20, 21)
GUICtrlSetLimit(-1, 2)
$He = GUICtrlCreateInput("", 96, 72, 20, 21)
GUICtrlSetLimit(-1, 2)
$Re = GUICtrlCreateInput("", 96, 96, 20, 21)
GUICtrlSetLimit(-1, 2)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Ma = GUICtrlCreateInput("", 144, 192, 40, 21)
GUICtrlSetLimit(-1, 3)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = $GUI_EVENT_CLOSE
        Exit
    Case $nMsg = $Ok
        MsgBox('','','')
        IniWrite("\config.ini", "Variables", "$hs", GuiCtrlRead($he))
        IniWrite("\config.ini", "Variables", "$mi", GuiCtrlRead($mi))
        IniWrite("\config.ini", "Variables", "$r", GuiCtrlRead($re))
        IniWrite("\config.ini", "Variables", "$mt", GuiCtrlRead($ma))
    EndSelect
WEnd

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ty, but I now get a second popup that you entered and the original doesn't close, and no .ini is created or written to :P

I'm hoping for it to save to the ini, close the gui, and continue on with a script that follows. Thanks guys! Really trying to learn this but I'm out of brainpower x_x

Edited by oozma

Share this post


Link to post
Share on other sites

Ty, but I now get a second popup that you entered and the original doesn't close, and no .ini is created or written to :P

I'm hoping for it to save to the ini, close the gui, and continue on with a script that follows. Thanks guys! Really trying to learn this but I'm out of brainpower x_x

I am not sure I understand - the ini will be in the same folder that you ran your code from. Works for me.

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

I've tried running as the script and as the compiled version. Both don't give me any .ini file. Even tried to resave to a different directory and search the entire computer for config.ini :/

Share this post


Link to post
Share on other sites

I've tried running as the script and as the compiled version. Both don't give me any .ini file. Even tried to resave to a different directory and search the entire computer for config.ini :/

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

;;LABELS
$MTrainer = GUICreate("mt", 210, 265, 269, 218)
$MM = GUICtrlCreateLabel("Mm:", 16, 56, 70, 17)
$HS = GUICtrlCreateLabel("hs:", 32, 80, 50, 17)
$R = GUICtrlCreateLabel("r:", 56, 104, 29, 17)
$Ok = GUICtrlCreateButton("Ok", 56, 232, 105, 25, 0)
$Max = GUICtrlCreateLabel("m:", 8, 200, 135, 17)
$Hotkey = GUICtrlCreateLabel("hk", 88, 32, 38, 17)
$S = GUICtrlCreateGroup("ss", 8, 8, 161, 169)
;;INPUTS
$Mi = GUICtrlCreateInput("", 96, 48, 20, 21)
GUICtrlSetLimit(-1, 2)
$He = GUICtrlCreateInput("", 96, 72, 20, 21)
GUICtrlSetLimit(-1, 2)
$Re = GUICtrlCreateInput("", 96, 96, 20, 21)
GUICtrlSetLimit(-1, 2)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Ma = GUICtrlCreateInput("", 144, 192, 40, 21)
GUICtrlSetLimit(-1, 3)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $Ok
            MsgBox('', 'WRITING INI FILE', '')
            IniWrite("config.ini", "Variables", "$hs", GUICtrlRead($He))
            IniWrite("config.ini", "Variables", "$mi", GUICtrlRead($Mi))
            IniWrite("config.ini", "Variables", "$r", GUICtrlRead($Re))
            IniWrite("config.ini", "Variables", "$mt", GUICtrlRead($Ma))
            
            $file = FileOpen("config.ini", 0)

            ; Check if file opened for reading OK
            If $file = -1 Then
                MsgBox(0, "Error", "Unable to open file.")
                Exit
            Else
                MsgBox('','FILE EXIST', 'config.ini')
            EndIf

            FileClose($file)
            
            
    EndSelect
WEnd

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites

Thank you that did it :unsure: Actually just tried removing the \ before refreshing this page. TY very much! Only thing left is the GUI closing after clicking OK. doesn't seem to close :P

Share this post


Link to post
Share on other sites

Thank you that did it :unsure: Actually just tried removing the \ before refreshing this page. TY very much! Only thing left is the GUI closing after clicking OK. doesn't seem to close :P

Have you tried telling it to close? :D AutoIt is no mindreader you know :D

Share this post


Link to post
Share on other sites

AutoIt is no mindreader you know :P

Say what? No wonder I've been having problems. I thought that the "auto" in AutoIt meant automatic and now you're telling me that it won't automatically do something.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Thanks Admiral, I thought the GUI creator would put that command in there by itself, so I didnt think it needed one. All good to go. Ty guys!

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  
Followers 0