Sign in to follow this  
Followers 0
~L.a.p.i.g~

Checkboxes...

4 posts in this topic

I am wondering how to check if a certain checkbox is checked and perform an action when you click a button. Help would be great.

Share this post


Link to post
Share on other sites



From the help file

#include <GUIConstants.au3>

GUICreate ("My GUI (GetControlState)")
$n=GUICtrlCreateCheckbox ("checkbox",10,10)
GUICtrlSetState (-1,1)       ; checked 

GUISetState ()    ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

msgbox (0,"state",StringFormat("GUICtrlRead=%d\nGUICtrlGetState=%d",GUICtrlRead($n),GUICtrlGetState($n)))

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

#include <GUIConstants.au3>

Opt ("GUIOnEventMode", 1)

GUICreate ("My GUI")

$n = GuiCtrlCreateCheckbox("CheckBox",10,10)

GuiCtrlSetOnEvent( $n , "Function")

GuiSetState()

Func Function ()

$readen=GuiCtrlRead($n)

if $readen = 1

msgbox(0,"Is Set Check)

Else

MsgBox(0,"Isnt checked")

Endif

EndFunc

This also might work no?

Edited by Misha

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>

GUICreate ("My GUI")

$n = GuiCtrlCreateCheckbox("CheckBox",10,10)

;GuiCtrlSetOnEvent( $n , "Function")

GuiSetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

MsgBox(0, "", "Dialog was closed")

Exit

Case $msg = $n

Function ()

EndSelect

WEnd

Func Function ()

$readen=GuiCtrlRead($n)

if $readen = 1 then

msgbox(0,"","Is Set Check")

Else

MsgBox(0,"","Isnt checked")

Endif

EndFunc

;Now it works ;-)

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