Sign in to follow this  
Followers 0
subfighter

How To Grey Out Disable OTher CheckBoxes

4 posts in this topic

Hello,

I have like 5 check boxes that the user can select which turn on/off for a command flvmdi.exe that i am running..

but if one of the Switches is selected it needs to be run alone with out any other switches. i need to DISABLE or GREYOUT the other check boxes so the user can not select them and I will uncheck them..

I was trying to figure out on how to GREY OUT the Checkbox and make it uncheckable?

any help appreciated

Share this post


Link to post
Share on other sites



Hello,

I have like 5 check boxes that the user can select which turn on/off for a command flvmdi.exe that i am running..

but if one of the Switches is selected it needs to be run alone with out any other switches. i need to DISABLE or GREYOUT the other check boxes so the user can not select them and I will uncheck them..

I was trying to figure out on how to GREY OUT the Checkbox and make it uncheckable?

any help appreciated

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $Checkbox[3]
$Form1 = GUICreate("Form1", 633, 447, 197, 149)
;checkboxes must be created together with no other controls created bewteen the first and last
;otherwise Case A won't work
$Checkbox[0] = GUICtrlCreateCheckbox("one", 136, 88, 97, 17)
$Checkbox[1] = GUICtrlCreateCheckbox("two", 136, 136, 97, 17)
$Checkbox[2] = GUICtrlCreateCheckbox("three", 136, 184, 97, 17)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Checkbox[0] to $Checkbox[2];Case A
             if GUICtrlRead($nMsg) = $GUI_CHECKED Then
                for $n = 0 to 2
                    if $Checkbox[$n] <> $nMsg Then
                        GUICtrlSetState($Checkbox[$n],$GUI_DISABLE)
                    EndIf
                Next
             Else
                 for $n = 0 to 2
                    if $Checkbox[$n] <> $nMsg Then
                        GUICtrlSetState($Checkbox[$n],$GUI_ENABLE)
                    EndIf
                Next
             EndIf
             

    EndSwitch
WEnd

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

GuiCtrlSetState will do the trick:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 174, 173, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 20, 25, 97, 17)
GUICtrlSetOnEvent(-1, "Checkbox1Click")
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 20, 55, 97, 17)
GUICtrlSetOnEvent(-1, "Checkbox2Click")
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 20, 90, 97, 17)
GUICtrlSetOnEvent(-1, "Checkbox3Click")
$Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 20, 125, 97, 17)
GUICtrlSetOnEvent(-1, "Checkbox4Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Sleep(100)
WEnd

Func Checkbox1Click()
    If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
        GUICtrlSetState($Checkbox2, $GUI_DISABLE)
        GUICtrlSetState($Checkbox3, $GUI_DISABLE)
        GUICtrlSetState($Checkbox4, $GUI_DISABLE)
    Else
        GUICtrlSetState($Checkbox2, $GUI_ENABLE)
        GUICtrlSetState($Checkbox3, $GUI_ENABLE)
        GUICtrlSetState($Checkbox4, $GUI_ENABLE)
    EndIf
EndFunc
Func Checkbox2Click()
    If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then
        GUICtrlSetState($Checkbox1, $GUI_DISABLE)
        GUICtrlSetState($Checkbox3, $GUI_DISABLE)
        GUICtrlSetState($Checkbox4, $GUI_DISABLE)
    Else
        GUICtrlSetState($Checkbox1, $GUI_ENABLE)
        GUICtrlSetState($Checkbox3, $GUI_ENABLE)
        GUICtrlSetState($Checkbox4, $GUI_ENABLE)
    EndIf
EndFunc
Func Checkbox3Click()
    If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then
        GUICtrlSetState($Checkbox2, $GUI_DISABLE)
        GUICtrlSetState($Checkbox1, $GUI_DISABLE)
        GUICtrlSetState($Checkbox4, $GUI_DISABLE)
    Else
        GUICtrlSetState($Checkbox2, $GUI_ENABLE)
        GUICtrlSetState($Checkbox1, $GUI_ENABLE)
        GUICtrlSetState($Checkbox4, $GUI_ENABLE)
    EndIf
EndFunc
Func Checkbox4Click()
    If GUICtrlRead($Checkbox4) = $GUI_CHECKED Then
        GUICtrlSetState($Checkbox2, $GUI_DISABLE)
        GUICtrlSetState($Checkbox3, $GUI_DISABLE)
        GUICtrlSetState($Checkbox1, $GUI_DISABLE)
    Else
        GUICtrlSetState($Checkbox2, $GUI_ENABLE)
        GUICtrlSetState($Checkbox3, $GUI_ENABLE)
        GUICtrlSetState($Checkbox1, $GUI_ENABLE)
    EndIf
EndFunc
Func Form1Close()
    Exit
EndFunc

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

thanks for your examples as they help me figure it out... as i just started using autoit a couple of days so i get stuck on some issues... but you guys got me in the right direction.

the part i was missing was the $GUI_DISABLE and SETSTATE.. makes sense now after seeing your examples.. i posted my script below in case somebody else wants another of example..

GUICtrlSetState($addx_switch, $GUI_DISABLE)

thanks again

CODE
#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.12.1

Author: myName

Script Function:

Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <GUIConstantsEx.au3>

#include <StaticConstants.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()

#cs

Local $defaultstatus = "Ready", $status, $filemenu, $fileitem

Local $helpmenu, $saveitem, $infoitem, $exititem, $recentfilesmenu

Local $separator1, $viewmenu, $viewstatusitem, $okbutton, $cancelbutton

Local $statuslabel, $msg

#ce

Local $tab, $tab0, $tab0but_inputfile, $tab0but_inputfilepath, $tab0but_outputfile, $tab0but_outputfilepath

Local $tab1, $flvfolder, $tab1but_inputfolder, $tab1but_inputfolderpath, $tab1but_outputfolder, $tab1but_outputfolderpath

Local $tab2, $tab2OK, $msg

Local $flvfile, $message, $flvfileselected

Local $addx_switch, $addk_switch, $addl_switch, $addv_switch, $addp_switch, $adde_switch

Local $var, $button_process_files, $answer, $commandline, $x_switch, $k_switch, $l_switch, $v_switch, $p_switch, $e_switch

local $read_state

GUICreate("Flvtool2 GUI - FLV MetaData Injector", 400, 400) ; will create a dialog box that when displayed is centered

$tab = GUICtrlCreateTab(10, 10, 380, 115)

; FIRST TAB FLV FILE INPUT

$tab0 = GUICtrlCreateTabItem("Single File"); will display Tab Text

GUICtrlSetState(-1, $GUI_SHOW) ; will be display first

GUICtrlCreateLabel("Input FLV File:", 20, 40, 300, 20)

$tab0but_inputfile = GUICtrlCreateButton("...", 365, 55, 20, 20)

$tab0but_inputfilepath = GUICtrlCreateInput($flvfile, 20, 55, 340, 18)

GUICtrlCreateLabel("Output FLV File:", 20, 80, 300, 20)

$tab0but_outputfile = GUICtrlCreateButton("...", 365, 95, 20, 20)

$tab0but_outputfilepath = GUICtrlCreateInput($flvfile, 20, 95, 340, 18)

; SECOND TAB FLV FOLDER INPUT

$tab1 = GUICtrlCreateTabItem("All Files In A Folder"); will display Tab Text

GUICtrlCreateLabel("Input FLV File Folder:", 20, 40, 300, 20)

$tab1but_inputfolder = GUICtrlCreateButton("...", 365, 55, 20, 20)

$tab1but_inputfolderpath = GUICtrlCreateInput($flvfolder, 20, 55, 340, 18)

GUICtrlCreateLabel("Output FLV File Folder:", 20, 80, 300, 20)

$tab1but_outputfolder = GUICtrlCreateButton("...", 365, 95, 20, 20)

$tab1but_outputfolderpath = GUICtrlCreateInput($flvfolder, 20, 95, 340, 18)

GUICtrlCreateTabItem("") ; end tabitem definition

GUICtrlCreateLabel("MetaData Options:", 10, 135, 300, 20)

$addk_switch = GUICtrlCreateCheckbox ("Include 'Keyframes' Object", 10, 150, 360, 20)

GUICtrlSetState($addk_switch, $GUI_CHECKED)

$addl_switch = GUICtrlCreateCheckbox ("Inject onLastSecond Event", 10, 170, 360, 20)

GUICtrlSetState($addl_switch, $GUI_CHECKED)

$addx_switch = GUICtrlCreateCheckbox ("Create .XML Files", 10, 190, 360, 20)

GUICtrlSetState($addx_switch, $GUI_UNCHECKED)

$addp_switch = GUICtrlCreateCheckbox ("Display Output Progress", 10, 210, 360, 20)

GUICtrlSetState($addp_switch, $GUI_UNCHECKED)

$adde_switch = GUICtrlCreateCheckbox ("Inject Custom String Data 'xtradata'", 10, 230, 360, 20)

GUICtrlSetState($adde_switch, $GUI_UNCHECKED)

$addv_switch = GUICtrlCreateCheckbox ("Extract Metadata as XMLs, No Injection", 10, 320, 360, 20)

GUICtrlSetState($addv_switch, $GUI_UNCHECKED)

$button_process_files = GUICtrlCreateButton("Inject MetaData", 290, 360, 100, 30)

GUISetState()

; Run the GUI until the dialog is closed

While 1

$msg = GUIGetMsg()

If $msg = $addv_switch Then

$read_state = GUICtrlRead ($addv_switch)

If $read_state = 1 Then

GUICtrlSetState($addk_switch, $GUI_DISABLE)

GUICtrlSetState($addl_switch, $GUI_DISABLE)

GUICtrlSetState($addx_switch, $GUI_DISABLE)

GUICtrlSetState($adde_switch, $GUI_DISABLE)

GUICtrlSetState($tab0but_outputfile, $GUI_DISABLE)

GUICtrlSetState($tab0but_outputfilepath, $GUI_DISABLE)

MsgBox(4096,"",$read_state)

ElseIf $read_state = 4 Then

GUICtrlSetState($addk_switch, $GUI_ENABLE)

GUICtrlSetState($addl_switch, $GUI_ENABLE)

GUICtrlSetState($addx_switch, $GUI_ENABLE)

GUICtrlSetState($adde_switch, $GUI_ENABLE)

GUICtrlSetState($tab0but_outputfile, $GUI_ENABLE)

GUICtrlSetState($tab0but_outputfilepath, $GUI_ENABLE)

MsgBox(4096,"",$read_state)

EndIf

Endif

If $msg = $tab0but_inputfile Then ; Dialong To Select the Input File

$message = "Select A Video File"

$flvfile= FileOpenDialog($message, @WorkingDir & "\", "Videos (*.flv)", 1 )

If @error Then

;MsgBox(4096,"","No File chosen")

Else

GUICtrlSetData ($tab0but_inputfilepath, $flvfile)

GUICtrlSetData ($tab0but_outputfilepath, $flvfile)

EndIf

EndIf

If $msg = $tab0but_outputfile Then ; Dialong to Select the Output File

$message = "Save Video File As"

$flvfile= FileOpenDialog($message, @WorkingDir & "\", "Videos (*.flv)", 1 )

If @error Then

;MsgBox(4096,"","No File chosen")

Else

GUICtrlSetData ($tab0but_outputfilepath, $flvfile)

EndIf

EndIf

If $msg = $tab1but_inputfolder Then ; Dialong To Select the Input Folder

$message = "Select Input Folder"

$flvfolder= FileSelectFolder($message, "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", 2 + 8)

If @error Then

MsgBox(4096,"","No Folder chosen")

Else

GUICtrlSetData ($tab1but_inputfolderpath, $flvfolder)

GUICtrlSetData ($tab1but_outputfolderpath, $flvfolder)

EndIf

EndIf

If $msg = $button_process_files Then

If FileExists(GUICtrlRead ($tab0but_inputfilepath)) Then

$answer=MsgBox(4+32+4096, "Inject MetaData", "Do You Want To Inject the MetaData Now!")

If $answer = 6 Then

$var = GUICtrlRead ($addk_switch)

If $var = 1 Then

$k_switch = "/k " ;yes

ElseIf $var = 4 Then

$k_switch = "" ;no

EndIf

;MsgBox(0, "Include Keyframes Object", $k_switch)

$var = GUICtrlRead ($addl_switch)

If $var = 1 Then

$l_switch = "/l " ;yes

ElseIf $var = 4 Then

$l_switch = "" ;no

EndIf

;MsgBox(0, "Inject ofLastSecond Event", $l_switch)

$var = GUICtrlRead ($addx_switch)

If $var = 1 Then

$x_switch = "/x " ;yes

ElseIf $var = 4 Then

$x_switch = "" ;no

EndIf

;MsgBox(0, "Create .XML Files", $x_switch)

$var = GUICtrlRead ($addp_switch)

If $var = 1 Then

$p_switch = "/p " ;yes

ElseIf $var = 4 Then

$p_switch = "" ;no

EndIf

;MsgBox(0, "Display Output Progress", $p_switch)

$var = GUICtrlRead ($adde_switch)

If $var = 1 Then

$e_switch = "/e " ;yes

ElseIf $var = 4 Then

$e_switch = "" ;no

EndIf

;MsgBox(0, "Inject Custom String Data 'xtradata'", $e_switch)

$var = GUICtrlRead ($addv_switch)

If $var = 1 Then

$v_switch = "/v " ;yes

$k_switch = "" ;no

$l_switch = "" ;no

$x_switch = "" ;no

$e_switch = "" ;no

ElseIf $var = 4 Then

$v_switch = "" ;no

EndIf

;MsgBox(0, "Extract Metadata as XMLs, No Injection", $v_switch)

;MsgBox(4096, "OUTPUT", GUICtrlRead ($tab0but_outputfilepath))

;$commandline = "flvmdi.exe /k " & $tab0but_inputfilepath & $tab0but_outputfilepath

$commandline = "flvmdi.exe " & GUICtrlRead ($tab0but_inputfilepath) & " " & GUICtrlRead ($tab0but_outputfilepath) & " " & $k_switch & $l_switch & $x_switch & $p_switch & $e_switch & $v_switch

;Run(@ComSpec & " /k " & $commandline)

MsgBox(4096, "YES", $commandline)

ElseIf $answer = 7 Then

MsgBox(4096, "NO", "Exit")

EndIf

Else

MsgBox(4096,"File Does Not Exist", "Please Enter Complete Filename and Path")

EndIf

;MsgBox(0, "KEYFRAME", GUICtrlRead ($tab0but_outputfilepath))

EndIf

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

WEnd

EndFunc ;==>Example

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