def456 Posted May 29, 2018 Share Posted May 29, 2018 Hi, I want when Gui open, read the state of Checkbox and Radio and GuiCtrlSetState it When button close clicked, I want to save state of Checkbox and Radio what should I use to save it? Here is my code #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUICreate(" ", 242, 139, Default, Default) $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 40, 81, 17) $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 120, 40, 97, 17) $Radio1 = GUICtrlCreateRadio("Radio1", 16, 72, 81, 25) $Radio2 = GUICtrlCreateRadio("Radio2", 128, 72, 65, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Can you help me fixing it ? Thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 29, 2018 Moderators Share Posted May 29, 2018 def456, Welcome to the AutoIt forum. But please pay attention to where you post - the "Examples" section where you started this thread is clearly marked: "Do not post general support questions here". I have moved it for you, but would ask you to be more careful in future. M23 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...
def456 Posted May 30, 2018 Author Share Posted May 30, 2018 11 hours ago, Melba23 said: def456, Welcome to the AutoIt forum. But please pay attention to where you post - the "Examples" section where you started this thread is clearly marked: "Do not post general support questions here". I have moved it for you, but would ask you to be more careful in future. M23 I'm sorry, I will more carefully in the future. Thanks for remind me. Link to comment Share on other sites More sharing options...
Subz Posted May 30, 2018 Share Posted May 30, 2018 (edited) Here is one way, using Ini to save config settings. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $sConfig = @ScriptDir & "\Config.ini" GUICreate(" ", 242, 139, Default, Default) Local $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 40, 81, 17) GUICtrlSetState($Checkbox1, IniRead($sConfig, "Config", "Checkbox1", 4)) Local $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 120, 40, 97, 17) GUICtrlSetState($Checkbox2, IniRead($sConfig, "Config", "Checkbox2", 4)) Local $Radio1 = GUICtrlCreateRadio("Radio1", 16, 72, 81, 25) GUICtrlSetState($Radio1, IniRead($sConfig, "Config", "Radio1", 4)) Local $Radio2 = GUICtrlCreateRadio("Radio2", 128, 72, 65, 25) GUICtrlSetState($Radio2, IniRead($sConfig, "Config", "Radio2", 4)) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE IniWrite($sConfig, "Config", "Checkbox1", GUICtrlRead($Checkbox1)) IniWrite($sConfig, "Config", "Checkbox2", GUICtrlRead($Checkbox2)) IniWrite($sConfig, "Config", "Radio1", GUICtrlRead($Radio1)) IniWrite($sConfig, "Config", "Radio2", GUICtrlRead($Radio2)) Exit EndSwitch WEnd Edited May 30, 2018 by Subz Link to comment Share on other sites More sharing options...
def456 Posted May 30, 2018 Author Share Posted May 30, 2018 4 hours ago, Subz said: Here is one way, using Ini to save config settings. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $sConfig = @ScriptDir & "\Config.ini" GUICreate(" ", 242, 139, Default, Default) Local $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 40, 81, 17) GUICtrlSetState($Checkbox1, IniRead($sConfig, "Config", "Checkbox1", 4)) Local $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 120, 40, 97, 17) GUICtrlSetState($Checkbox2, IniRead($sConfig, "Config", "Checkbox2", 4)) Local $Radio1 = GUICtrlCreateRadio("Radio1", 16, 72, 81, 25) GUICtrlSetState($Radio1, IniRead($sConfig, "Config", "Radio1", 4)) Local $Radio2 = GUICtrlCreateRadio("Radio2", 128, 72, 65, 25) GUICtrlSetState($Radio2, IniRead($sConfig, "Config", "Radio2", 4)) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE IniWrite($sConfig, "Config", "Checkbox1", GUICtrlRead($Checkbox1)) IniWrite($sConfig, "Config", "Checkbox2", GUICtrlRead($Checkbox2)) IniWrite($sConfig, "Config", "Radio1", GUICtrlRead($Radio1)) IniWrite($sConfig, "Config", "Radio2", GUICtrlRead($Radio2)) Exit EndSwitch WEnd Thanks . Is that the only way to save State of Radio and Checkbox ? Link to comment Share on other sites More sharing options...
Subz Posted May 30, 2018 Share Posted May 30, 2018 No, Link to comment Share on other sites More sharing options...
antonioj84 Posted May 31, 2018 Share Posted May 31, 2018 you can create a property file as well to do that 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