Jump to content

Select ALL/ Select NONE checkoxes


Recommended Posts

Hello,

I have found the script below for helping me to choose which programs to install.

How can i create a button(or hokey) for "Select ALL/ Select NONE" check-boxes?

Here is the script i found:

#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <TreeViewConstants.au3>
_Singleton("Automated Launcher Script")
Opt("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)
HotKeySet("^!x", "_Close");Exit on Ctrl+Alt+X

Global $ininame = "_process_launcher.ini"

If $CmdLine[0] == 1 Then
    $ininame = $CmdLine[1]
EndIf

If Not FileExists($ininame) Then
    MsgBox(0x2030, "Error", "No """ & $ininame & """! Writing empty .ini file.")
    _CreateINI()
    Exit
EndIf

Global $slist = IniReadSectionNames($ininame)
If @error == 1 Then
    MsgBox(0x2030, "Error", "Read fail for " & $ininame & "! File empty or invalid.")
    Exit
EndIf
Global $guiWindow = GUICreate("Process Queue", 250, 250)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Close")
Global $guiButton = GUICtrlCreateButton("OK", 85, 210, 80, 30, $BS_DEFPUSHBUTTON)
GUICtrlSetOnEvent($guiButton, "_ButtonEvent")
Global $guiLabel = GUICtrlCreateLabel("Choose programs to Install:", 10, 10, 180, 15)
Global $guiTree = GUICtrlCreateTreeView(10, 30, 230, 175, $TVS_CHECKBOXES)
Global $tItem[$slist[0] + 1]
For $i = 1 To $slist[0]
    $tItem[$i] = GUICtrlCreateTreeViewItem($slist[$i], $guiTree)
Next
GUISetState(@SW_SHOW)

Sleep(86400000)

Func _ButtonEvent()
    Local $msgres = MsgBox(0x2124, "Confirm Selection", "Are you sure of your selection?", 86400, $guiWindow)
    If $msgres == 6 Then
        GUISetState(@SW_HIDE)
        Local $pID, $path, $dir, $checked = False
        For $i = 1 To $slist[0]
            If BitAND(GUICtrlRead($tItem[$i]), $GUI_CHECKED) Then
                $checked = True
                $path = IniRead($ininame, $slist[$i], "path", "<no path>")
                $dir = IniRead($ininame, $slist[$i], "dir", ".\")
                $pID = Run($path, $dir, @SW_HIDE)
                If @error <> 0 Then
                    MsgBox(0x2030, "Error", "Failed to run " & $slist[$i] & ": """ & $path & """!", 86400, $guiWindow)
                EndIf
                ProcessWaitClose($pID)
            EndIf
        Next
        GUISetState(@SW_SHOW)
        If $checked Then
            MsgBox(0x2000, "Process Launcher", "Process queue finished!", 86400, $guiWindow)
            _Close()
        Else
            MsgBox(0x2000, "Process Launcher", "No process selected!", 86400, $guiWindow)
        EndIf
    EndIf
EndFunc

Func _CreateINI()
    Local $file = FileOpen($ininame, 2)
    FileWriteLine($file, ";INI file for Process Launcher")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";INI file format is:")
    FileWriteLine($file, ";[SECTION]")
    FileWriteLine($file, ";KEY = VALUE")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";Section name is label for installation script.")
    FileWriteLine($file, ";Key(s) are: Path, Dir")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";Processes are launched in succeeding order, one at a time.")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";Sample:")
    FileWriteLine($file, ";[Installer Label 1]")
    FileWriteLine($file, ";path = someprogram.exe")
    FileWriteLine($file, ";[Installer Label 2]")
    FileWriteLine($file, ";path = .\path\someprogram.exe")
    FileWriteLine($file, ";[Installer Label 3]")
    FileWriteLine($file, ";path = D:\path\someprogram.exe")
    FileWriteLine($file, ";dir = D:\path")
    FileWriteLine($file, ";")
    FileWriteLine($file, ";Start entries here:")
    FileClose($file)
EndFunc

Func _Close()
    Exit
EndFunc

Thank you

Edited by Orao
Link to comment
Share on other sites

  • Moderators

rao,

This should give you the idea: :)

#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <TreeViewConstants.au3>

Opt("GUIOnEventMode", 1)

Global $guiWindow = GUICreate("Process Queue", 250, 250)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Close")
Global $guiButton = GUICtrlCreateButton("OK", 85, 210, 80, 30, $BS_DEFPUSHBUTTON)
GUICtrlSetOnEvent($guiButton, "_ButtonEvent")
Global $ChkButton = GUICtrlCreateButton("Chk All", 5, 210, 80, 30)
GUICtrlSetOnEvent($ChkButton, "_ChkEvent")
Global $ClrButton = GUICtrlCreateButton("Clr All", 165, 210, 80, 30)
GUICtrlSetOnEvent($ClrButton, "_ClrEvent")
Global $guiLabel = GUICtrlCreateLabel("Choose programs to Install:", 10, 10, 180, 15)
Global $guiTree = GUICtrlCreateTreeView(10, 30, 230, 175, $TVS_CHECKBOXES)
Global $tItem[5]
For $i = 0 To 4
    $tItem[$i] = GUICtrlCreateTreeViewItem($i, $guiTree)
Next
GUISetState(@SW_SHOW)

While 1
    Sleep(10)
WEnd

Func _ButtonEvent()
EndFunc

Func _ChkEvent()
    For $i = 0 To UBound($tItem) - 1
        GUICtrlSetState($tItem[$i], $GUI_CHECKED)
    Next
EndFunc

Func _ClrEvent()
    For $i = 0 To UBound($tItem) - 1
        GUICtrlSetState($tItem[$i], $GUI_UNCHECKED)
    Next
EndFunc

Func _Close()
    Exit
EndFunc

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...