Jump to content
Sign in to follow this  
Epsilon

I'm in need of help

Recommended Posts

Epsilon

I am trying to learn AutoIt, and i'm doing okay. But i have a question. How do I make a checkbox change what a button does. Like, if i had a button that displayed a messagebox saying "Hello" how would i set up a checkbox that when checked, the button will instead display a messagebox saying "Goodbye"

Share this post


Link to post
Share on other sites
0xdefea7

Here is an example. You should look at GUICtrlRead() in the helpfile:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Example", 182, 73, 192, 124)
$Checkbox1 = GUICtrlCreateCheckbox("GoodBye", 16, 8, 97, 17)       ; Here is the checkbox - $Checkbox1 is the variable we need to read using GUICtrlRead()
$Button1 = GUICtrlCreateButton("Button1", 8, 40, 163, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1                              ; Button1 pressed
            If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then  ; Checkbox is checked
                MsgBox(0, "Example", "Goodbye!")
            Else                        ; Checkbox not checked
                MsgBox(0, "Example", "Hello!")
            EndIf
    EndSwitch
WEnd
Edited by 0xdefea7

Share this post


Link to post
Share on other sites
water

Welcome to AutoIt and the forum!

Could you please give your threads a meaningful title? Everyone on the forum is seeking for help.

The better you describe your problem in the title the more help you will get :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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  

×