Jump to content

Recommended Posts

Posted (edited)

how can i tell if a CheckBox is Checked... and can save it too a ini file..

This doesnt work...

$SaveGUI = GuiCreate("Save New file", 311, 60,(@DesktopWidth-311)/2, (@DesktopHeight-60)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Input_1 = GuiCtrlCreateInput("New", 140, 10, 160, 20)
$Label_2 = GuiCtrlCreateLabel("State the Name of file and Hit Save.", 10, 10, 120, 30)
$Button_3 = GuiCtrlCreateButton("Save", 70, 40, 150, 20)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        GUIDelete($SaveGUI)
        ExitLoop
    Case $msg = $Button_3
        _FileCreate(GUICtrlRead($Input_1)&".ini")
        If FileExists(GUICtrlRead($Input_1)&".ini") Then
IniWrite(GUICtrlRead($Input_1)&".ini", "Settings", "test", GUICtrlRead($test))
            GUIDelete($SaveGUI)
            ExitLoop
        Else
            MsgBox( 2, "File Error", "Unable to create new file.")
            GUIDelete($SaveGUI)
            ExitLoop
        EndIf
        
    EndSelect
WEnd

this is only a snipit... $test = GUICtrlCreateCheckbox("RaNdOm", 144, 164, 109, 17)

i was thinking that if it was checked it would return 1... but it isnt working like that...(i also have 'load' code that works if the ini has a 1 then the Check the Checkbox)

Edited by lopolop
Posted (edited)

This will write the checkbox state to the ini.
IniWrite(GUICtrlRead($Input_1)&".ini", "Settings", "Checkbox", GUICtrlRead($Checkbox))oÝ÷ Ù8b³¥·vØ^xÛ¶Ø^²Ö­zíç!yÉ£h­Á«,j÷jëh×6GUICtrlSetState($Checkbox, IniRead(GUICtrlRead($Input_1)&".ini", "Settings", "Checkbox", ""))oÝ÷ Ûú®¢×«Þjëh×6IniWrite(GUICtrlRead($Input_1)&".ini", "Settings", "Checkbox", GUICtrlRead($Checkbox))

Should that Be a 1 for the state?

[Edit]

Ok nvm i got it when the CheckBox is UnChecked the IniWrites 4... lol y is it 4 and not 0 idk... but thanks!

Edited by lopolop
Posted

I have

IniWrite(GUICtrlRead($Input_1)&".ini", "Settings", "Checkbox", GUICtrlRead($Checkbox))

Should that Be a 1 for the state?

[Edit]

Ok nvm i got it when the CheckBox is UnChecked the IniWrites 4... lol y is it 4 and not 0 idk... but thanks!

Yep, alternatively you can use $GUI_CHECKED and $GUI_UNCHECKED. They are defined in the GUIConstants.au3 include.
Posted

would this same technique work for writing to and parsing txt files instead of ini files to save or retrieve the state of checkboxes?

Amp Energy Drink: the official sponsor of me scripting at 2AM.

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
×
×
  • Create New...