leuce Posted May 15, 2006 Posted May 15, 2006 G'day everyone I'm trying to create a GUI in which the user has to check all checkboxes and press the OK button before the script continues. I just don't know how to check if the user has checked all the checkboxes. My solution doesn't work... I thought that since if the state of the checkbox is changed, it returns the value 1, then all I have to do is check if the sum of the values equal the number of checkboxes. Unfortunately, I don't know the syntax to do that (and I can't find it under the math functions in the Help file). Here's what I have (the last bit doesn't work, but you'll get the idea): expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainwindow = GUICreate("Hello World", 200, 100) $checkCN1 = GUICtrlCreateCheckbox ("Checkbox 1", 20, 20) $checkCN2 = GUICtrlCreateCheckbox ("Checkbox 2", 20, 40) $checkCN3 = GUICtrlCreateCheckbox ("Checkbox 3", 20, 60) $checkCN4 = GUICtrlCreateCheckbox ("Checkbox 4", 20, 80) $okbutton = GUICtrlCreateButton("OK", 20, 100, 60) GUICtrlSetOnEvent($okbutton, "OKButton") GUISetState(@SW_SHOW) While 1 Sleep(1000) WEnd Func OKButton() Dim $a, $b, $c, $d, $e $a = GUICtrlGetState ($checkCN1) $b = GUICtrlGetState ($checkCN2) $c = GUICtrlGetState ($checkCN3) $d = GUICtrlGetState ($checkCN4) $e = ($a+$b+$c+$d) If $e = (4) Then MsgBox(0, "GUI Event", "You ticked all four boxes") Else MsgBox(0, "GUI Event", "You did not tick all four boxes") Endif EndFunc Any ideas? I really miss an abundance of GUI examples in the Help file. Thanks Samuel
Developers Jos Posted May 15, 2006 Developers Posted May 15, 2006 You need to use GUICtrlRead() $a = GUICtrlRead($checkCN1) $b = GUICtrlRead($checkCN2) $c = GUICtrlRead($checkCN3) $d = GUICtrlRead($checkCN4) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Don N Posted May 15, 2006 Posted May 15, 2006 GuitCtrlGetState() returns the current state of the check box. This will return $GUI_CHECKED or $GUI_UNCHECKED when called, not a 1 if checked and a 0 in uncecked. _____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper
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