Jump to content

Ini create/write problem


Recommended Posts

So I have this form

and want autoit to write in a ini file the content entered in the input box and the result of the 3 checkboxes (if its checked or not)

But for some reason its not writing the correct values in the ini file...

What am I doing wrong?

And what is the default result for checkboxes to say if they are checked or unchecked and how can I write that on a ini file?

Not even the delay... and thats number on a input box ... its not writing anything as it should on the ini file

$Form1 = GUICreate("Form1", 210, 191, 297, 322)
$del = GUICtrlCreateInput("", 96, 40, 97, 21)
$cb1 = GUICtrlCreateCheckbox("1", 8, 112, 97, 17)
$cb2 = GUICtrlCreateCheckbox("2", 8, 136, 97, 17)
$cb3 = GUICtrlCreateCheckbox("3", 8, 160, 97, 17)
$Velocidade = GUICtrlCreateLabel("Velocidade:", 8, 40, 84, 24)
GUICtrlSetFont(-1, 12, 800, 0, "Myriad Pro Light")
$Label1 = GUICtrlCreateLabel("(Recomendado 3000 - 5000ms)", 8, 64, 190, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Titulo", 8, 88, 171, 24)
GUICtrlSetFont(-1, 12, 800, 0, "Myriad Pro Light")
$bt1 = GUICtrlCreateButton("Save", 104, 128, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$delay=GUICtrlRead ( $del,0 )
$cbr1=GUICtrlRead ( $cb1,0 )
$cbr2=GUICtrlRead ( $cb2,0 )
$cbr3=GUICtrlRead ( $cb3,0 )

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $bt1
IniWrite("C:\Users\username\Desktop\myfile.ini", "section1", "Delay", $delay)
IniWrite("C:\Users\username\Desktop\myfile.ini", "section1", "1", $cbr1)
IniWrite("C:\Users\username\Desktop\myfile.ini", "section1", "2", $cbr2)
IniWrite("C:\Users\username\Desktop\myfile.ini", "section1", "3", $cbr3)
Exit
EndSwitch
WEnd

Oh and I also want it to when I click the Save button to create the ini (even overwriting it it already exists) and close the form... Is it right? Cuz I had some doubts about that (Case $bt1 thingy)

Edited by kaneco
Link to comment
Share on other sites

  • Moderators

kaneco,

You need to read the input and radios just before you write them - you were reading them immediately after they were created, so they were obviously empty.

Look at this: :blink:

#include <GUIConstantsEx.au3>

$sIniFile = "C:\Users\username\Desktop\myfile.ini"

$Form1 = GUICreate("Form1", 210, 191, 297, 322)
$del = GUICtrlCreateInput("", 96, 40, 97, 21)
$cb1 = GUICtrlCreateCheckbox("1", 8, 112, 97, 17)
$cb2 = GUICtrlCreateCheckbox("2", 8, 136, 97, 17)
$cb3 = GUICtrlCreateCheckbox("3", 8, 160, 97, 17)
$Velocidade = GUICtrlCreateLabel("Velocidade:", 8, 40, 84, 24)
GUICtrlSetFont(-1, 12, 800, 0, "Myriad Pro Light")
$Label1 = GUICtrlCreateLabel("(Recomendado 3000 - 5000ms)", 8, 64, 190, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Titulo", 8, 88, 171, 24)
GUICtrlSetFont(-1, 12, 800, 0, "Myriad Pro Light")
$bt1 = GUICtrlCreateButton("Save", 104, 128, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $bt1
            $delay = GUICtrlRead($del, 0)
            $cbr1 = GUICtrlRead($cb1, 0)
            $cbr2 = GUICtrlRead($cb2, 0)
            $cbr3 = GUICtrlRead($cb3, 0)
            IniWrite($sIniFile, "section1", "Delay", $delay)
            IniWrite($sIniFile, "section1", "1", $cbr1)
            IniWrite($sIniFile, "section1", "2", $cbr2)
            IniWrite($sIniFile, "section1", "3", $cbr3)
            Exit
    EndSwitch
WEnd

The IniWrite function automatically create or overwrite an existing file.

And you seem to have understood the "Case $bt1 thingy" quite well. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...