mikestern Posted August 30, 2020 Share Posted August 30, 2020 Hi There, I seek your help on the following issue, I have a GUI where a bunch of inputs will be saved on ini file (setting.ini) I am getting an issue to save the checked Checkbox state and then read it from ini file. other data got reflected when the gui is called to be edited except Checkbox Status remains always unchecked even it was saved as checked in ini file Data are saved as 1 or 4 which is correct but I want the box state to be saved as $GUI_CHECKED or $GUI_UNCHECKED also Below is logic of saving the value of check box. (Extract of target code only) expandcollapse popupWhile 1 Other condition of code here xxx xxx xx Case $Button_SaveSettings; By pressing save button below variable data will be saved In ini file Global $collect_Checkbox1 = GUICtrlRead($Checkbox1) IniWrite($IniFile, "Data", "Status ", $collect_Checkbox1); save the input in ini file GUIDelete($Setting_GUI) GUICtrlSetState($ButtonSetting, $GUI_ENABLE) EndSwitch EndSwitch WEnd EndFunc ; Func Settingform() xxxx xxxx $IniFile = @ScriptDir & "\Setting.ini" Global $Read_Checkbox1 = IniRead($IniFile, "Data", "Status ", ""); Read from Ini file and reflect it on Setting for GUI $AdditionalOption = GUICtrlCreateLabel("Take snapshot and save picture", 40, 434, 165, 17); Label $Checkbox1 = GUICtrlCreateCheckbox($Read_Checkbox1, 24, 434, 17, 17) GUICtrlSetState($Checkbox1, $GUI_UNCHECKED); Unchecked by default Other code part xxx xxx Any help is really appreciated Mike Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 30, 2020 Moderators Share Posted August 30, 2020 Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
mikell Posted August 30, 2020 Share Posted August 30, 2020 (edited) You might try this : $Checkbox1 = GUICtrlCreateCheckbox("Take snapshot and save picture", 24, 434, 150, 17) GUICtrlSetState($Checkbox1, $Read_Checkbox1) Edited August 30, 2020 by mikell typo Link to comment Share on other sites More sharing options...
Dan_555 Posted August 30, 2020 Share Posted August 30, 2020 (edited) I'm using following functions with the checkboxes: Func _IsChecked($idControlID) ;Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED ;Returns true or false (oneliner) ;The lines below convert true and false to numbers - 1 and 0 local $x=BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED If $x = True Then Return 1 Return 0 EndFunc ;==>_IsChecked Func _CheckUncheck($id, $nr) If $nr = 0 Then GUICtrlSetState($id, $GUI_UNCHECKED) Else GUICtrlSetState($id, $GUI_CHECKED) EndIf EndFunc ;==>_CheckUncheck eventually (additionally to the @mikell's change) you should change the default value of the following line Global $Read_Checkbox1 = IniRead($IniFile, "Data", "Status ", ""); Read from Ini file and reflect it on Setting for GUI If the Ini file is not available then you may want to have the last , "" changed into True/False or 1/0 depending which value type you are using. Edited August 30, 2020 by Dan_555 Some of my script sourcecode Link to comment Share on other sites More sharing options...
mikestern Posted August 31, 2020 Author Share Posted August 31, 2020 Hi Guys, Sorry Melba 23 for posting on the wrong category. Mikemell: It worked perfectly, It is so simple and I don't understand how I miss it Thank you Man Dan_555: Your function will fit a combo box I have also with slight modification. Thank you guys, you really saved my day! Great Autoit and great contributors Mike Link to comment Share on other sites More sharing options...
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