CyberDrag0n Posted January 7, 2007 Posted January 7, 2007 I've created a simple checkbox..My problem is how do I iniwrite the value to a inifile so that I dont have to check the box everytime I re-run the script? CODE#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 130, 82, 193, 115) $Checkbox1 = GUICtrlCreateCheckbox("Sample", 32, 40, 65, 17) $Group1 = GUICtrlCreateGroup("SampleBox", 0, 0, 129, 81) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;iniread here.. While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Iniwrite("settings.ini", "Primary", "Sample", Bitand(GUICtrlRead($Checkbox1 ),$GUI_CHECKED) = $GUI_CHECKED ; This is wrong..pls help Exit EndSwitch WEnd I'm new and I just want to learn.. I go through the help files but it doest say that how to store value of checkbox (checked/uncheck) into an ini file. Thank you
Zedna Posted January 7, 2007 Posted January 7, 2007 (edited) $value1 = IniRead('name.ini', "Values", "Sample1", "0") If $value = '1' Then GUICtrlSetState($checkbox1, $GUI_CHECKED)INI content:[Values] Sample1=1EDIT: corrected variable name, thanks Helge Edited January 7, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Helge Posted January 7, 2007 Posted January 7, 2007 $checkbox1 = IniRead('name.ini', "Values", "Sample1", "0") If $checkbox1 = '1' Then GUICtrlSetState($checkbox1, $GUI_CHECKED) Zedna...I'll give you some time to rethink that one
Zedna Posted January 7, 2007 Posted January 7, 2007 (edited) Also writing: #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 130, 82, 193, 115) $Checkbox1 = GUICtrlCreateCheckbox("Sample", 32, 40, 65, 17) $Group1 = GUICtrlCreateGroup("SampleBox", 0, 0, 129, 81) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $value1 = IniRead('settings.ini', "Primary", "Sample", "0") If $value1 = '1' Then GUICtrlSetState($checkbox1, $GUI_CHECKED) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE If Bitand(GUICtrlRead($Checkbox1 ),$GUI_CHECKED) = $GUI_CHECKED Then $value1 = "1" Else $value1 = "0" EndIf Iniwrite("settings.ini", "Primary", "Sample", $value1) Exit EndSwitch WEnd INI content: [Primary] Sample=1 Edited January 7, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Zedna Posted January 7, 2007 Posted January 7, 2007 (edited) $checkbox1 = IniRead('name.ini', "Values", "Sample1", "0") If $checkbox1 = '1' Then GUICtrlSetState($checkbox1, $GUI_CHECKED) Zedna...I'll give you some time to rethink that one At first look I didn't noticed his IniWrite attempt with names of INI, options so I write some names from my head. In my second post it's correct. EDIT: you are right I was using control variable also for it's value :"> Edited January 7, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Helge Posted January 7, 2007 Posted January 7, 2007 (edited) Exactly EDIT : Removed code...didn't see you'd updated it. Edited January 7, 2007 by Helge
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