Jump to content

Reading from a check box control


Yata
 Share

Recommended Posts

Bit of a simplistic question, but how do I retrieve the results from a check box control? Meaning checking if it's checked or not. I know to use GUIControlRead, I'm just lacking the method behind the madness.

Thanks.

Edited by Yata
Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
Local $checkCN, $msg
GUICreate("My GUI Checkbox") ; will create a dialog box that when displayed is centered

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

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

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $checkCN
            ConsoleWrite("CheckBox=" & BitAND(GUICtrlRead($checkCN), $GUI_CHECKED) & @LF)
    EndSelect
WEnd

Link to comment
Share on other sites

I need it to do something depending on if it's checked, your example is really helpful but it only exchanges a numerical value where the checkbox is being evaluated as the action is executing, where I'm thinking I need to evaluate it first THEN do something with it depending on it's state.

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
Local $checkCN, $msg
GUICreate("My GUI Checkbox") ; will create a dialog box that when displayed is centered

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

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

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $checkCN
            If BitAND(GUICtrlRead($checkCN), $GUI_CHECKED) Then
                ConsoleWrite("Do this when checked" & @LF)
            Else
                ConsoleWrite("Do this when not checked" & @LF)
            EndIf
    EndSelect
WEnd

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...