Jump to content
Sign in to follow this  

How to check an autoit GUI checkbox

Recommended Posts


I have a gui that queries a database for previous selections before load. All input boxes are updating and retaining correctly. Checkbox selections are not. Here is what have tried.

When a Checkbox is checked, its GUICtrlRead is 1, if not it is 4

I am saving the value of the checkbox to a database:

$sExec = "UPDATE Users SET Eleven='" & GUICtrlRead($Checkbox1) & "' WHERE User_Name='" & $UserName & "'" ; Change a record

If _SQLite_Exec($hDB, $sExec) = $SQLITE_OK Then ConsoleWrite("Debug: Successfully updated a record." & @LF)

This is working. It is storing 1 or 4 correctly depending on if the box was checked or not.

The next time I load it should set the box to 1 or 4 from that database save, but it is actually renaming the checkbox and not checking/unchecking it

GUICtrlSetData($Checkbox1, $aRow[10])

Anyone have any idea what's going on here?

simple value test below to show 1 and 4

#include <GUIConstants.au3>

$Form1 = GUICreate("Update Profile", 780, 380)

$UpdateProfileButton = GUICtrlCreateButton("Update", 700, 350, 75, 25, 0)

$checkCN = GUICtrlCreateCheckbox("CHECKBOX 1", 10, 10, 120, 20)

GUISetState() ; will display an dialog box with 1 checkbox

; Run the GUI until the dialog is closed

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

If $msg = $UpdateProfileButton Then

MsgBox(64, "Results", GUICtrlRead($checkCN))



Edited by Hatcheda

Share this post

Link to post
Share on other sites

No problem, hope it works out for you :)

Share this post

Link to post
Share on other sites

Hey it worked out well! I reduced the code to:

If $aRow[10] = 1 then GuiCtrlSetState($Checkbox1, $GUI_CHECKED)

Since 4 is the default load value (Unchecked) I didn't need it :)

Share this post

Link to post
Share on other sites

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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.