Sign in to follow this  
Followers 0
Epsilon

I'm in need of help

3 posts in this topic

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



#2 ·  Posted (edited)

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

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 (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

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