Jump to content
Sign in to follow this  
MadCoder

A couple GUI questions

Recommended Posts

MadCoder

As you may be able to tell, I'm very new to A3'S GUI API's. I can't seen to find any reference to Enabling / Disabling buttons.

I need to disable the install button upon click and well as the cancel.

Also, How do I check the if a Checkbox has been click or not. What I plan on doing is a IF/THEN/ELSE. If the checkbox is checked then

run autoit installation script, else... move on. If there is a better way, I'm always opening to learn.

Can someone give me a simple working example checkbox and/or button example? Something I can actually learn from?

Below is my GUI code:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiButton.au3>
#Include <GUIMenu.au3>

#Region ### START Koda GUI section ### Form=Q:\Autoit3\koda\Forms\Launcher.kxf
$Launcher = GUICreate("Workstation Deployment", 368, 461, 278, 170)
$Group1 = GUICtrlCreateGroup(" Select Applications to Install ", 0, 5, 365, 361)
$chkBoost = GUICtrlCreateCheckbox("Boost C++ Libraries", 43, 152, 150, 25)
$chkCUDA = GUICtrlCreateCheckbox("CUDA", 43, 181, 144, 25)
$chkAce = GUICtrlCreateCheckbox("Ace", 43, 239, 128, 25)
$chkTortoise = GUICtrlCreateCheckbox("Tortoise SVN", 43, 210, 126, 25)
$chkMozilla = GUICtrlCreateCheckbox("Mozilla Firefox", 43, 36, 118, 25)
$chkIrfanview = GUICtrlCreateCheckbox("Irfanview", 43, 65, 104, 25)
$chkFaststone = GUICtrlCreateCheckbox("Fast Stone Viewer", 43, 94, 118, 25)
$chkDotNET = GUICtrlCreateCheckbox(".NET 2.0", 43, 123, 96, 25)
$Progress = GUICtrlCreateProgress(8, 325, 353, 33)
GUICtrlSetColor(-1, 0x808080)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$chkOmniorb = GUICtrlCreateCheckbox("omniORB", 227, 39, 110, 25)
$chkOpenrtm = GUICtrlCreateCheckbox("Open RTM", 227, 68, 88, 25)
$chkPython = GUICtrlCreateCheckbox("Python", 227, 97, 78, 25)
$chkYAML = GUICtrlCreateCheckbox("pyYAML", 227, 126, 64, 25)
$Checkbox5 = GUICtrlCreateCheckbox("Intel IPP", 227, 155, 70, 25)
$chkMatlab = GUICtrlCreateCheckbox("MatLab 2007", 227, 184, 96, 25)
$chkMssdk = GUICtrlCreateCheckbox("Microsoft SDK", 227, 213, 94, 25)
$chkAcrobat = GUICtrlCreateCheckbox("Adobe Acrobat 9", 227, 242, 112, 25)
$txtProgressText = GUICtrlCreateLabel("Current Installation Progress:", 7, 308, 138, 17)
GUICtrlSetColor(-1, 0xA0A0A4)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$btnInstall = GUICtrlCreateButton("&Start Installations", 256, 375, 109, 33, $WS_GROUP)
$btnCancel = GUICtrlCreateButton("&Cancel ", 134, 376, 109, 33, $WS_GROUP)
$Group2 = GUICtrlCreateGroup("", 0, 417, 365, 41)
$txtTime = GUICtrlCreateLabel("time", 8, 432, 23, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $btnInstall
    ;;;; Start



Case $btnCancel
    ;;;
    Exit
EndSwitch
WEnd

Share this post


Link to post
Share on other sites
colafrysen

Another sample

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 191, 191, 192, 124)
$Button1 = GUICtrlCreateButton("My button", 8, 160, 107, 25, $WS_GROUP)
$Radio1 = GUICtrlCreateRadio("Radio1", 8, 8, 113, 17)
$Checkbox1 = GUICtrlCreateCheckbox("Disable button", 8, 136, 97, 17)
$Radio2 = GUICtrlCreateRadio("Radio2", 8, 32, 113, 17)
$Radio3 = GUICtrlCreateRadio("Radio3", 8, 56, 113, 17)
$Label1 = GUICtrlCreateLabel("Label1", 8, 88, 113, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE ;You clicked the X
            Exit
        Case $Button1 ;You clicked the button
            MsgBox(0, "", "Hello!")
        Case $Radio1, $Radio2, $Radio3 ;You clicked a radio
            Switch $GUI_CHECKED
                Case GUICtrlRead($Radio1) ;Radio1 is Checked
                    GUICtrlSetData($Label1, "Radio 1 is Checked")
                Case GUICtrlRead($Radio2) ;Radio2 is Checked
                    GUICtrlSetData($Label1, "Radio 2 is Checked")
                Case GUICtrlRead($Radio3) ;Radio3 is Checked
                    GUICtrlSetData($Label1, "Radio 3 is Checked")
            EndSwitch
        Case $Checkbox1
            If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then ;checked - Disable button
                GUICtrlSetState($Button1, $GUI_DISABLE) ;Get these constants by opening "GUICtrlSetState" in the helpfile 
            Else
                GUICtrlSetState($Button1, $GUI_ENABLE) 
            EndIf
    EndSwitch
WEnd

[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.