Sign in to follow this  
Followers 0
serr57

Checkbox check

5 posts in this topic

Hi,

I have created a GUI with check box to install our applications.

Every thing works fine.

I would like now add a check box, named "all applications".

When I check this one, I would like that every check box in the form be automatically checked.

But I don't found how to do this.

Here a part of my script:

#include <ButtonConstants.au3>

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=C:\testgui.kxf

$Form1 = GUICreate("Automatic Software Installation", 633, 447, 192, 124)

GUISetBkColor(0xFFFFFF)

$Java = GUICtrlCreateCheckbox("Java 1.6.13", 8, 104, 130, 25)

GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

GUICtrlSetResizing(-1, $GUI_DOCKRIGHT+$GUI_DOCKHEIGHT)

GUICtrlSetTip(-1, "0")

$Citrix = GUICtrlCreateCheckbox("Citrix", 8, 136, 130, 25)

GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

GUICtrlSetResizing(-1, $GUI_DOCKRIGHT+$GUI_DOCKHEIGHT)

GUICtrlSetTip(-1, "0")

$Delphi = GUICtrlCreateCheckbox("Delphi 400", 8, 168, 130, 17)

GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

GUICtrlSetResizing(-1, $GUI_DOCKRIGHT+$GUI_DOCKHEIGHT)

GUICtrlSetTip(-1, "0")

$Izarc = GUICtrlCreateCheckbox("Izarc 3.81", 8, 192, 130, 25)

GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

GUICtrlSetResizing(-1, $GUI_DOCKRIGHT+$GUI_DOCKHEIGHT)

GUICtrlSetTip(-1, "0")

$Cancel = GUICtrlCreateButton("Cancel", 208, 360, 89, 41, $WS_GROUP)

$OK = GUICtrlCreateButton("OK", 352, 360, 89, 41, $WS_GROUP)

$WKS = GUICtrlCreateCheckbox("WKS Customisation", 8, 249, 130, 25)

GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

GUICtrlSetResizing(-1, $GUI_DOCKRIGHT+$GUI_DOCKHEIGHT)

GUICtrlSetTip(-1, "0")

$Swift = GUICtrlCreateCheckbox("Swift 6.0", 8, 219, 130, 25)

GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

GUICtrlSetResizing(-1, $GUI_DOCKRIGHT+$GUI_DOCKHEIGHT)

GUICtrlSetTip(-1, "0")

$All = GUICtrlCreateCheckbox("All Applications", 304, 104, 130, 17)

GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $OK

if GUICtrlRead ($all) = $GUI_CHECKED Then

GUICtrlSetState ($allapps, $GUI_CHECKED)

sleep (2000)

EndIf

if GUICtrlRead ($java) = $GUI_CHECKED Then

RunWait ("\\path\ParamToadd.exe")

EndIf

Exit

EndSwitch

WEnd

If some body can help me

serr57

Share this post


Link to post
Share on other sites



serr57,

Welcome to the AutoIt forum. :D

As simple way to do what you want is to see if the $All checkbox is checked during your loop and then check all the others if needed - like this:

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

        Case $OK

            If GUICtrlRead($Java) = $GUI_CHECKED Then
                RunWait("\\path\ParamToadd.exe")
            EndIf
            Exit
    EndSwitch

    If GUICtrlRead($All) = $GUI_CHECKED Then
        GUICtrlSetState($Java, $GUI_CHECKED)
        GUICtrlSetState($Citrix, $GUI_CHECKED)
        GUICtrlSetState($Delphi, $GUI_CHECKED)
        GUICtrlSetState($Izarc, $GUI_CHECKED)
        GUICtrlSetState($WKS, $GUI_CHECKED)
        GUICtrlSetState($Swift, $GUI_CHECKED)
    EndIf

WEnd

I hope that helps. :huggles:

M23

P.S. When you post code please use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here). Or press the blue button just under the BOLD toolbar button.


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

serr57,

Welcome to the AutoIt forum. :D

As simple way to do what you want is to see if the $All checkbox is checked during your loop and then check all the others if needed - like this:

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

        Case $OK

            If GUICtrlRead($Java) = $GUI_CHECKED Then
                RunWait("\\path\ParamToadd.exe")
            EndIf
            Exit
    EndSwitch

    If GUICtrlRead($All) = $GUI_CHECKED Then
        GUICtrlSetState($Java, $GUI_CHECKED)
        GUICtrlSetState($Citrix, $GUI_CHECKED)
        GUICtrlSetState($Delphi, $GUI_CHECKED)
        GUICtrlSetState($Izarc, $GUI_CHECKED)
        GUICtrlSetState($WKS, $GUI_CHECKED)
        GUICtrlSetState($Swift, $GUI_CHECKED)
    EndIf

WEnd

I hope that helps. :huggles:

M23

P.S. When you post code please use Code tags. Put [autoit ] before and [/autoit ] after your posted code (but omit the trailing space - it is only there so the tags display here). Or press the blue button just under the BOLD toolbar button.

Many thanks, it works fine.

But little question:

it is not possible to script something like this :

$allapps = ($swift, citrix.....)?

and after : GUICtrlSetState($allapps, $GUI_CHECKED)
?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

serr57,

Short answer = No.

Longer answer = if you create all the checkboxes in IMMEDIATE succession, you can use a loop to make things a little easier:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$hCheck_1 = GUICtrlCreateCheckbox("Box 1", 10, 10, 100, 20)
$hCheck_2 = GUICtrlCreateCheckbox("Box 2", 10, 30, 100, 20)
$hCheck_3 = GUICtrlCreateCheckbox("Box 3", 10, 50, 100, 20)
$hCheck_4 = GUICtrlCreateCheckbox("Box 4", 10, 70, 100, 20)
$hCheck_5 = GUICtrlCreateCheckbox("Box 5", 10, 90, 100, 20)

$hCheck_6 = GUICtrlCreateCheckbox("All", 10, 200, 100, 20)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    If GUICtrlRead($hCheck_6) = $GUI_CHECKED Then
        For $i = $hCheck_1 To $hCheck_5
            GUICtrlSetState($i, $GUI_CHECKED)
        Next
    Else
        For $i = $hCheck_1 To $hCheck_5
            GUICtrlSetState($i, $GUI_UNCHECKED)
        Next
    EndIf

WEnd

Now the top 5 turn on and off together when you check/uncheck the "All" box. This can be useful if you have a lot of checkboxes. :D

M23

Edit: When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. :huggles:

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Many thanks M23, this solution seems better for me.

Sorry for my post layout

This case is Resolved

#Resolved

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