Sign in to follow this  
Followers 0
imani

How to know if a checkbox state is changed

3 posts in this topic

Anyone can tell me how to know if the state of a checkbox is changed. For example the user in the GUI has selected a box that was previously not selected

Share this post


Link to post
Share on other sites



#include <GUIConstants.au3>

GUICreate("My GUI Checkbox")
$checkCN = GUICtrlCreateCheckbox ("CHECKBOX 1", 10, 10, 120, 20)
$label1 = GUICtrlCreateLabel ("unchecked", 10, 50, 120, 20)
GUISetState ()

While 1
    $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop

    If $msg = $checkCN Then 
        If IsChecked($checkCN ) Then 
            $state = 'checked'
        Else
            $state = 'unchecked'
        EndIf
        GUICtrlSetData ($label1 , $state)
    EndIf
Wend

Func IsChecked($control)
    Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc

See AutoIt helpfile for details...

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>

GUICreate("My GUI Checkbox")
$checkCN = GUICtrlCreateCheckbox ("CHECKBOX 1", 10, 10, 120, 20)
$label1 = GUICtrlCreateLabel ("unchecked", 10, 50, 120, 20)
GUISetState ()

While 1
    $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop

    If $msg = $checkCN Then 
        If IsChecked($checkCN ) Then 
            $state = 'checked'
        Else
            $state = 'unchecked'
        EndIf
        GUICtrlSetData ($label1 , $state)
    EndIf
Wend

Func IsChecked($control)
    Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc

See AutoIt helpfile for details...

Thanks Zedna For your help

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  
Followers 0