Sign in to follow this  
Followers 0
DarkHo

Save function using IniWrite

16 posts in this topic

#1 ·  Posted (edited)

Wheal Im trying to make a save button using IniWrite and a data.ini file the problems is i want to save all actions on the program like in all cases i have made. When i press save it saves all the actions in all of the chosen cases

Thanks :mellow:

Danke :(

Tack :lol:

Grazi :P

Edited by DarkHo

Share this post


Link to post
Share on other sites



#4 ·  Posted (edited)

DarkHo you really cannot expect people to provide code for you if you do not show any effort whatsoever. Try to explain what you want in more detail to begin with, as right now it's totally unclear. Second, have you even looked at the documentation? I suppose you have as you seem to use the IniWrite correctly so I do wonder what exactly is the problem?

Besides, you don't seem to have given us all your code as there will be no problems with that code if that's all. Well OK, you didn't define $Path2 yet...

Edited by d4ni

Share this post


Link to post
Share on other sites

DarkHo you really cannot expect people to provide code for you if you do not show any effort whatsoever. Try to explain what you want in more detail to begin with, as right now it's totally unclear. Second, have you even looked at the documentation? I suppose you have as you seem to use the IniWrite correctly so I do wonder what exactly is the problem?

Besides, you don't seem to have given us all your code as there will be no problems with that code if that's all. Well OK, you didn't define $Path2 yet...

Hmm :S ok i told you that i want to add more Cases to save int the same script


Share this post


Link to post
Share on other sites

DarkHo,

all the actions in all of the chosen cases

Do you mean by this that you want to save the current contents of Inputs, Combos, Checkboxes and so on to your Ini file?

If so:

- Where is the code for your GUI? We have no idea of what there is to save at the moment.

- Where do you want to save it? If you run under Vista or Win7 you need to think of UAC problems if your script might be placed in "Program Files".

- Where is the code you have tried so far? Writing Ini files is not difficult (because AutoIt does most of the work for you :( ) but, as d4ni has already pointed out, you need to show a bit of effort before anyone is going to help - let alone write the code for you!

Over to you! :mellow:

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

#7 ·  Posted (edited)

OK yes about the Inputs, Combos, Checkboxes and im using WIN XP and ini file. the ini file is added in the same folder that the program is in,

Edited by DarkHo

Share this post


Link to post
Share on other sites

DarkHo,

And the code you have tried so far?

And I do not mean the 2 lines that you posted a couple of posts above - I mean a GUI with a "Save" button and some controls together with YOUR version of the code to write the contents of the controls to an Ini file.

You realise that in the time you have spent giving us stupidly short replies, you could probably have coded the whole thing? You have a valid path for the Ini file and you have posted a command line with the correct syntax to write data to it - what exactly is it that you need in addition? :mellow:

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

I fear you may be flogging a dead horse Melba23

Global $IniPath = @ScriptDir & "\data.ini"

_WriteIni("Need", "Some", "Code")

Func _WriteIni($var1, $var2, $var3)
     IniWrite($IniPath, $var1, $var2, $var3)
EndFunc

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I have uploaded the au3 file and exe and ini file

this is only a test script. And how do i make the the script load from ini file ? :s

test.zip

Edited by DarkHo

Share this post


Link to post
Share on other sites

DarkHo,

Your code was perfectly good - well done! :mellow:

I have shown you here how to read the Ini file and set the controls to the saved values when you start - well, some of them anyway, you still need to do some work! :lol:

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

Global $IniPath = @ScriptDir & "\data.ini"

; read the saved input data from the ini file
$sSavedPath = IniRead($IniPath, "Data2", "program_info", "No Ini")
; read the saved checkbox data from the ini file
$iSavedFood = IniRead($IniPath, "Data2", "food", 0)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 181, 186, 192, 124)
$Path2 = GUICtrlCreateInput("", 32, 24, 137, 21)

; Put the ini data (if it exists) in the input
If $sSavedPath <> "No Ini" Then GUICtrlSetData($Path2, $sSavedPath)

$Button1 = GUICtrlCreateButton("Save", 112, 56, 49, 17, $WS_GROUP)
$Checkbox1 = GUICtrlCreateCheckbox("Food", 32, 96, 81, 17)

; Set the state of the check box to checked if required
If $iSavedFood = 1 Then GUICtrlSetState($Checkbox1, $GUI_CHECKED)

$Checkbox2 = GUICtrlCreateCheckbox("Write", 32, 120, 81, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Book", 32, 144, 81, 17)
$Button2 = GUICtrlCreateButton("Start", 120, 136, 41, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

        Case $Button1

            IniWrite($IniPath, "Data2", "program_info", GUICtrlRead($Path2))
            IniWrite($IniPath, "Data2", "food", GUICtrlRead($Checkbox1))
            IniWrite($IniPath, "Data2", "book", GUICtrlRead($Checkbox2))
    EndSwitch
WEnd

I hope that shows you what you need.

Do not be hesitant to post your code - you see that we are much more ready to help if we see that you have made an effort yourself first. :(

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

#12 ·  Posted (edited)

hehe thanks man but how do i fix the other 2 Checkboxes i cant fix it.

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

Global $IniPath = @ScriptDir & "\data.ini"

; read the saved input data from the ini file
$sSavedPath = IniRead($IniPath, "Data2", "program_info", "No Ini")
; read the saved checkbox data from the ini file
$iSavedFood = IniRead($IniPath, "Data2", "food", 0)
$iSavedWrite = IniRead($IniPath, "Data2", "food", 0)
$iSavedBook = IniRead($IniPath, "Data2", "food", 0)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 181, 186, 192, 124)
$Path2 = GUICtrlCreateInput("", 32, 24, 137, 21)

; Put the ini data (if it exists) in the input
If $sSavedPath <> "No Ini" Then GUICtrlSetData($Path2, $sSavedPath)

$Button1 = GUICtrlCreateButton("Save", 112, 56, 49, 17, $WS_GROUP)
$Checkbox1 = GUICtrlCreateCheckbox("Food", 32, 96, 81, 17)

; Set the state of the check box to checked if required
If $iSavedFood = 1 Then GUICtrlSetState($Checkbox1, $GUI_CHECKED)
If $iSavedWrite = 1 Then GUICtrlSetState($Checkbox2, $GUI_CHECKED)
If $iSavedBook = 1 Then GUICtrlSetState($Checkbox3, $GUI_CHECKED)

$Checkbox2 = GUICtrlCreateCheckbox("Write", 32, 120, 81, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Book", 32, 144, 81, 17)
$Button2 = GUICtrlCreateButton("Start", 120, 136, 41, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

        Case $Button1

            IniWrite($IniPath, "Data2", "program_info", GUICtrlRead($Path2))
            IniWrite($IniPath, "Data2", "food", GUICtrlRead($Checkbox1))
        IniWrite($IniPath, "Data2", "write", GUICtrlRead($Checkbox2))
            IniWrite($IniPath, "Data2", "book", GUICtrlRead($Checkbox3))
    EndSwitch
WEnd
Edited by DarkHo

Share this post


Link to post
Share on other sites

DarkHo,

You need to put the relevant If $iSaved... line AFTER the Checkbox has been created! :mellow:

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

Dont work if i check food all of them get checked

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=sd.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $IniPath = @ScriptDir & "\data.ini"

; read the saved input data from the ini file
$sSavedPath = IniRead($IniPath, "Data2", "program_info", "No Ini")
; read the saved checkbox data from the ini file
$iSavedFood = IniRead($IniPath, "Data2", "food", 0)
$iSavedWrite = IniRead($IniPath, "Data2", "food", 0)
$iSavedBook = IniRead($IniPath, "Data2", "food", 0)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 181, 186, 192, 124)
$Path2 = GUICtrlCreateInput("", 32, 24, 137, 21)

; Put the ini data (if it exists) in the input
If $sSavedPath <> "No Ini" Then GUICtrlSetData($Path2, $sSavedPath)

$Button1 = GUICtrlCreateButton("Save", 112, 56, 49, 17, $WS_GROUP)
$Checkbox1 = GUICtrlCreateCheckbox("Food", 32, 96, 81, 17)

; Set the state of the check box to checked if required
If $iSavedFood = 1 Then GUICtrlSetState($Checkbox1, $GUI_CHECKED)



$Checkbox2 = GUICtrlCreateCheckbox("Write", 32, 120, 81, 17)
If $iSavedWrite = 1 Then GUICtrlSetState($Checkbox2, $GUI_CHECKED)
$Checkbox3 = GUICtrlCreateCheckbox("Book", 32, 144, 81, 17)
If $iSavedBook = 1 Then GUICtrlSetState($Checkbox3, $GUI_CHECKED)
$Button2 = GUICtrlCreateButton("Start", 120, 136, 41, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

        Case $Button1

            IniWrite($IniPath, "Data2", "program_info", GUICtrlRead($Path2))
            IniWrite($IniPath, "Data2", "food", GUICtrlRead($Checkbox1))
        IniWrite($IniPath, "Data2", "write", GUICtrlRead($Checkbox2))
            IniWrite($IniPath, "Data2", "book", GUICtrlRead($Checkbox3))
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

DarkHo,

Notice anything? :(

$iSavedFood = IniRead($IniPath, "Data2", "food", 0)

$iSavedWrite = IniRead($IniPath, "Data2", "food", 0)

$iSavedBook = IniRead($IniPath, "Data2", "food", 0)

:mellow:

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

DarkHo,

Notice anything? :(

$iSavedFood = IniRead($IniPath, "Data2", "food", 0)

$iSavedWrite = IniRead($IniPath, "Data2", "food", 0)

$iSavedBook = IniRead($IniPath, "Data2", "food", 0)

:mellow:

M23

hehe yes im a fool :lol: i didn't see it :P hehe


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