sensalim Posted April 10, 2012 Posted April 10, 2012 Hi, I need help. I'm trying to create a simple GUI that contains: -several checkboxes maybe combobox and buttons -reads one ini file -if user checks a checkbox, update that ini file How would you do this? Thanks.
shanet Posted April 10, 2012 Posted April 10, 2012 Sensalim, do you know how to read/write an INI file?My code would do it in somewhat the following order:Create GUIRead INI fileSet GUI control statesEnter GUIMessage loopOn message, write to ini fileCloseHave a look at IniRead/IniWrite, GUI Messages, GUI Control StatesI think that should help push you in the right direction. Best of luck [font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS: %programfiles%/AutoIt3/autoit3.chm
sensalim Posted April 10, 2012 Author Posted April 10, 2012 The GUI needs to be running until manually closed. In an infinite loop, it needs to handle read ini and write ini at "same time".
Mikeman27294 Posted April 10, 2012 Posted April 10, 2012 Here is an example script. #include <GUIConstantsEx.au3> If Not FileExists(@ScriptDir&"Settings.ini") Then FileWrite(@ScriptDir&"Settings.ini", "[Settings]"&@CRLF&"Checkbox1=0"&@CRLF&"Checkbox2=1") EndIf $Gui = GUICreate("INI Checkbox Example", 200, 200) $Checkbox1 = GUICtrlCreateCheckbox("Checkbox 1", 50, 50) $Checkbox1Setting = IniRead(@ScriptDir&"Settings.ini", "Settings", "Checkbox1", 0) If $Checkbox1Setting = 1 Then GUICtrlSetState($Checkbox1, $GUI_CHECKED) EndIf $Checkbox2 = GUICtrlCreateCheckbox("Checkbox 2", 50, 100) $Checkbox2Setting = IniRead(@ScriptDir&"Settings.ini", "Settings", "Checkbox2", 0) If $Checkbox2Setting = 1 Then GUICtrlSetState($Checkbox2, $GUI_CHECKED) EndIf GUISetState(@SW_SHOW, $Gui) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Checkbox1 If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then IniWrite(@ScriptDir&"Settings.ini", "Settings", "Checkbox1", 1) Else IniWrite(@ScriptDir&"Settings.ini", "Settings", "Checkbox1", 0) EndIf Case $Checkbox2 If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then IniWrite(@ScriptDir&"Settings.ini", "Settings", "Checkbox2", 1) Else IniWrite(@ScriptDir&"Settings.ini", "Settings", "Checkbox2", 0) EndIf EndSwitch WEnd Now please read the help file because this is pretty basic stuff.
sensalim Posted April 10, 2012 Author Posted April 10, 2012 (edited) Ok I didn't explain this right. The GUI needs to handle any changes made to the ini file whether by itself or by someone else editing the ini or by some other program making modification to that ini file. Sorry for any trouble. Edit: I changed it to onevent mode and put "read ini" function in the while loop and it seems to work. Is this not the right way or inefficient way? Edited April 10, 2012 by sensalim
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