Check all or clear all checkboxes

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Check all or clear all checkboxes

29 Nov 2018, 02:16

I managed to restore TabTitiles with spaces :D
Win10 Tweaks.v2.00.zip
(3.98 KiB) Downloaded 82 times
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Check all or clear all checkboxes

29 Nov 2018, 04:39

I managed to take control of colors on my side, we could have done it before, but cleaning up the options to 0 or 1, it was easier to see.
Win10 Tweaks.v3.00.zip
(3.12 KiB) Downloaded 86 times
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

29 Nov 2018, 06:14

Intresting :)

Tho the zip file isnt healthy ;) so i cant watch what you are doing :)
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Check all or clear all checkboxes

30 Nov 2018, 04:05

Final suggestion: write a class to handle "Select XXX" buttons and colors

Code: Select all

;-------------------------------------------------------------------------------
; Menu.ahk
; by wolf_II
;-------------------------------------------------------------------------------
; Challenge: write a class to handle "Select XXX" buttons and colors



#NoEnv
#SingleInstance Force

    new Menu("Installatiemenu nov 2018")
    .Layout("Registers", "Settings", "Programs")
    .Tab_Size(600, 400)
    .Show(50, 50)

return ; end of auto-execute section

#Include Pages\Registers.ahk
#Include Pages\Settings.ahk
#Include Pages\Programs.ahk

GuiClose:
ExitApp



;===============================================================================
class Menu { ; handles "Select XXX" buttons and colors
;===============================================================================

    ;{ Class variables };
    static Children := {} ;}

    ;{ Instance variables };
    Tab_Width   := A_ScreenWidth // 2
    Tab_Height  := A_ScreenHeight // 2
    Tab_List    := "" ;}

    __New(WinTitle) { ; constructor
        Gui, Menu: New, LabelGui, %WinTitle%
    }

    Layout(args*) { ; configure
        Loop, % args.length() ; FName = also name of #Include-files
            FName := args[A_Index], _List .= "|" %FName%()
        this.Tab_List := LTrim(_List, "|")
        return this ; chain
    }

    Tab_Size(w, h) { ; configure
        this.Tab_Width := w
        this.Tab_Height := h
        return this ; chain
    }

    AddText(ByRef Ctrl) { ; populate tab with text
        Gui, Add, Text, % Ctrl[1], % Ctrl[2]
    }

    AddCheckbox(ByRef Box) { ; populate tab in 2 columns
    ;-----------------------------------
        local pos := (Box[4] & 1) ; flip even/odd
            ? "yp x" this.Tab_Width // 2    ; 2, 4, 6, 8, ...
            : "y+3 xs"                      ; 1, 3, 5, 7, ...

        local Color := Box[1] ? "Green Checked" : "Red"
        local VarName := Box[2]
        local Box_onClick := this.toggleColour.Bind(this)

        Gui, Add, Checkbox, %pos% c%Color% v%VarName%, % Box[3]
        GuiControl +g, %VarName%, % Box_onClick
    }

    toggleColour(hWnd) { ; all the Checkboxes come here for colouring
        GuiControlGet, State,, %hWnd%
        GuiControl, % "+c" (State ? "Green" : "Red"), %hWnd%
    }

    AddTab(i, ByRef Child) { ; populate Tab2 with child-pages
    ;-----------------------------------
        Gui, Tab, %i%

        if (Child.Boxes.Length()) { ; add buttons
            Gui, Add, Button, HWNDhAll Section, Select All
            Gui, Add, Button, HWNDhNone x+m, Select None
            SelectAll_onClick := this.SelectAll.Bind(this)
            SelectNone_onClick := this.SelectNone.Bind(this)
            GuiControl +g, %hAll%, % SelectAll_onClick
            GuiControl +g, %hNone%, % SelectNone_onClick
        } else
            Gui, Add, Text, w0 h0 Section, dummy

        for each, CBox in Child.Boxes
            this.AddCheckbox(CBox)

        for each, TBox in Child.Texts
            this.AddText(TBox)

        if (Child.Callback) {
            Gui, Add, Button, HWNDhCtrl xs, Start
            Start_onClick := Func(Child.Callback).Bind(this)
            GuiControl +g, %hCtrl%, % Start_onClick
        }
    }

    SelectAll() { ; all the "Select All" buttons come here
    ;-----------------------------------
        GuiControlGet, Tab_Name,, SysTabControl321

        for each, Child in Menu.Children
            if (Child.Title = Tab_Name)
                break

        for each, VarName in Child.VarNames {
            GuiControl,, %VarName%, 1
            GuiControl, +cGreen, %VarName%
        }
    }

    SelectNone() { ; all the "Select None" buttons come here
    ;-----------------------------------
        GuiControlGet, Tab_Name,, SysTabControl321

        for each, Child in Menu.Children
            if (Child.Title = Tab_Name)
                break

        for each, VarName in Child.VarNames {
            GuiControl,, %VarName%, 0
            GuiControl, +cRed, %VarName%
        }
    }

    Show(x := "Center", y := "Center") { ; create & show GUI
    ;-----------------------------------
        w := this.Tab_Width, h := this.Tab_Height
        Gui, Add, Tab2, w%w% h%h%, % this.Tab_List
        Gui, Font, s10, Verdana

        for i, Child in this.Children ; iterate through tabs
            this.AddTab(i, Child)

        Gui, Show, x%x% y%y%
    }



    ;===========================================================================
    class Page { ; contains various controls, and an optional Start button
    ;===========================================================================

        ;{ Instance variables };
        Title    := ""  ; Tab title
        CallBack := ""  ; Start button
        VarNames := []  ; collection
        Boxes    := []  ; Checkbox controls
        Texts    := [] ;} Text controls

        __New(Title, CallBack := "") { ; constructor
            this.Title := Title
            this.CallBack := CallBack
            Menu.Children.Push(this)
        }

        AddCheckbox(Flag, VarName, Text) { ; register
            this.VarNames.Push(VarName)
            this.Boxes.Push([Flag, VarName, Text, this.Boxes.Length()])
            return this ; chain
        }

        AddText(Options, Text) { ; register
            this.Texts.Push([Options, Text, this.Texts.Length()])
            return this ; chain
        }

    } ; end of class

} ; end of class
Spoiler
Spoiler
Spoiler
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

30 Nov 2018, 13:41

I will check into that later, the script what i have now, works... and i'm very glad with it :)

i will let you know how this one is working!
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

13 Dec 2018, 06:18

Hello Mr Wolf_II ;)

i've been away from a while, and started to change the script which i had use for a cople of times, but encountered a few problems with it (renaming a tab with spaces causing errors) so copied and pasted your latest spoilers and now i am working with it, just to let you know..... so i do appriciate your effort and now i'm using your latest build :)... tho i just started to convert everything from the old to the new
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

13 Dec 2018, 06:43

I just tried to convert some of it, but i aleady stuck.. so i will work with the old script instead and wont take any of your time
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Check all or clear all checkboxes

13 Dec 2018, 06:52

Thanks for the feed back. :D

In case there is a problem or a feature request, let me know.

Edit: Oops, lemme read first

Edit2: no worries, I have more time than ability, if I can be of help to you, it would be my pleasure.
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

13 Dec 2018, 07:48

Thank you, i really appriciate this, i'm still trying to 'understand' your script, but when i was just starting a encounter a problem

Code: Select all

; Registers.ahk

Registers() {
    new Menu.Page(Title := "Registers", "Start_Registers")
    .AddCheckbox( 1, "Delete_people_icon", "Delete icon -> People <- from taskbar")
    return Title
}

	  if Delete_people_icon = 1
	{
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People , PeopleBand, 00000000
CoordMode, ToolTip
ToolTip , just a second and wait till every script is loaded... Deleting people icon from the taskbar..., 0, 20, WhichToolTip
Sleep, 100
ToolTip
	}
when i press Start, nothing happens...
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Check all or clear all checkboxes

13 Dec 2018, 08:05

new Menu.Page(Title := "Registers", "Start_Registers") has two parameters,
use the second parameter ("Start_Registers") again for declaring a function like this:

Code: Select all

; Registers.ahk

Registers() {
    new Menu.Page(Title := "Registers", "Start_Registers")
    .AddCheckbox( 1, "Delete_people_icon", "Delete icon -> People <- from taskbar")
    return Title
}

Start_Registers() {

	  if Delete_people_icon = 1
	{
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People , PeopleBand, 00000000
CoordMode, ToolTip
ToolTip , just a second and wait till every script is loaded... Deleting people icon from the taskbar..., 0, 20, WhichToolTip
Sleep, 100
ToolTip
	}
}
I hope that helps.
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

13 Dec 2018, 08:12

Sorry for the mistake... i've seen this 10 seconds before i get to notifcation mail......... but i did :

Code: Select all

; Registers.ahk

Registers() {
    new Menu.Page(Title := "Registers", "Start_Registers")
    .AddCheckbox( 1, "Delete_people_icon", "Delete icon -> People <- from taskbar")
    return Title
}

Start_Registers() {

	  if Delete_people_icon = 1
	{
; RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People , PeopleBand, 00000000
CoordMode, ToolTip
ToolTip , just a second and wait till every script is loaded... Deleting people icon from the taskbar..., 0, 20, WhichToolTip
Sleep, 1000
ToolTip
	}
}
I've exclude the regwrite to run because of the danger ;P
added a sleep 1000

i should get a tooltip

maybe it just a tooltip problem (i look into it right now)
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

13 Dec 2018, 08:19

Well i dont know what i am doing wrong...

the msgbox works, tooltip doesnt and the regwrite doesnt do anything too

Code: Select all

; Registers.ahk

Registers() {
    new Menu.Page(Title := "Registers", "Start_Registers")
    .AddCheckbox( 1, "Delete_people_icon", "Delete icon -> People <- from taskbar")
    return Title
}

Start_Registers() {
    MsgBox, TEST ; works
	  if Delete_people_icon = 1 ; does not work
	{
RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People , PeopleBand, 00000000 ; does not work
CoordMode, ToolTip
ToolTip , just a second and wait till every script is loaded... Deleting people icon from the taskbar..., 0, 20, WhichToolTip
Sleep, 1000
ToolTip
	}
}
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

13 Dec 2018, 08:21

Oh well, i just deleted 2 }
and now it works.... dont know if it works with other scripts tho.... still busy :P

Added: no that doesnt work either.......
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Check all or clear all checkboxes

13 Dec 2018, 08:27

Try this:

Code: Select all

Start_Registers() {
    global 
    Gui, Submit, NoHide
    ....
I hope that helps.
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

13 Dec 2018, 08:32

Ok this is very strange...

i will put the 2 scripts with and without msgbox, the 1st one works a bit, the 2nd doesnt work...

Code: Select all

; Registers.ahk

Registers() {
    new Menu.Page(Title := "Registers", "Start_Registers")
    .AddCheckbox( 1, "Delete_people_icon", "Delete icon -> People <- from taskbar")
    .AddCheckbox( 1, "Folder_options", "Change folder options (unhide and see ext.)")
    return Title
}

Start_Registers() {

	  if Delete_people_icon = 1
    MsgBox, TEST
	{
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People , PeopleBand, 00000000
CoordMode, ToolTip
ToolTip , just a second and wait till every script is loaded... Deleting people icon from the taskbar..., 0, 20, WhichToolTip
Sleep, 1000
ToolTip
	}
}

	  if Folder_options = 1
	{
RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer, ShowRecent, 00000000
CoordMode, ToolTip
ToolTip , just a second and wait till every script is loaded... Opties voor verkenner zijn ingesteld zoals het zien van verborgen bestanden en extenties verbergen..., 0, 20, WhichToolTip
Sleep, 1000
ToolTip
	}

Code: Select all

; Registers.ahk

Registers() {
    new Menu.Page(Title := "Registers", "Start_Registers")
    .AddCheckbox( 1, "Delete_people_icon", "Delete icon -> People <- from taskbar")
    .AddCheckbox( 1, "Folder_options", "Change folder options (unhide and see ext.)")
    return Title
}

Start_Registers() {

	  if Delete_people_icon = 1

	{
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People , PeopleBand, 00000000
CoordMode, ToolTip
ToolTip , just a second and wait till every script is loaded... Deleting people icon from the taskbar..., 0, 20, WhichToolTip
Sleep, 1000
ToolTip
	}
}

	  if Folder_options = 1
	{
RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer, ShowRecent, 00000000
RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer, ShowFrequent, 00000000
RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState, FullPath, 00000001
RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, LaunchTo, 1
RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 00000001
RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, HideFileExt, 00000000
RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, ShowSuperHidden, 00000001
CoordMode, ToolTip
ToolTip , just a second and wait till every script is loaded... Opties voor verkenner zijn ingesteld zoals het zien van verborgen bestanden en extenties verbergen..., 0, 20, WhichToolTip
Sleep, 1000
ToolTip
	}
only msgbox makes the difference
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

13 Dec 2018, 08:37

Ok, well your suggestion seems to work, only the following line doesnt work

.AddCheckbox( 1, "Folder_options", "Change folder options (unhide and see ext.)")

Code: Select all

; Registers.ahk

Registers() {
    new Menu.Page(Title := "Registers", "Start_Registers")
    .AddCheckbox( 1, "Delete_people_icon", "Delete icon -> People <- from taskbar")
    .AddCheckbox( 1, "Folder_options", "Change folder options (unhide and see ext.)")
    return Title
}

Start_Registers() {
    global 
    Gui, Submit, NoHide

	  if Delete_people_icon = 1

	{
RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People , PeopleBand, 00000000
CoordMode, ToolTip
ToolTip , just a second and wait till every script is loaded... Deleting people icon from the taskbar..., 0, 20, WhichToolTip
Sleep, 1000
ToolTip
	}
}

	  if Folder_options = 1
	{
RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer, ShowRecent, 00000000
CoordMode, ToolTip
ToolTip , just a second and wait till every script is loaded... Opties voor verkenner zijn ingesteld zoals het zien van verborgen bestanden en extenties verbergen..., 0, 20, WhichToolTip
Sleep, 1000
ToolTip
	}
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Check all or clear all checkboxes

13 Dec 2018, 08:40

Try this:

Code: Select all

; Registers.ahk

Registers() {
    new Menu.Page(Title := "Registers", "Start_Registers")
    .AddCheckbox( 1, "Delete_people_icon", "Delete icon -> People <- from taskbar")
    .AddCheckbox( 1, "Folder_options", "Change folder options (unhide and see ext.)")
    return Title
}

Start_Registers() {
    global
    Gui, Submit, NoHide

	  if Delete_people_icon = 1

	{
;~ RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People , PeopleBand, 00000000
CoordMode, ToolTip
ToolTip , just a second and wait till every script is loaded... Deleting people icon from the taskbar..., 0, 20, WhichToolTip
Sleep, 1000
ToolTip
	}

	  if Folder_options = 1
	{
;~ RegWrite, REG_DWORD, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer, ShowRecent, 00000000
CoordMode, ToolTip
ToolTip , just a second and wait till every script is loaded... Opties voor verkenner zijn ingesteld zoals het zien van verborgen bestanden en extenties verbergen..., 0, 20, WhichToolTip
Sleep, 1000
ToolTip
	}
}
I move one closing curly bracket.
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

13 Dec 2018, 08:43

haha, well, this is very odd...... when i turn around the order, the script works it should be, so
works:
if Folder_options = 1
if Delete_people_icon = 1

now works:
if Delete_people_icon = 1
if Folder_options = 1
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

13 Dec 2018, 08:45

I was too late with my reply..... it works now.......

thanx!
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Check all or clear all checkboxes

13 Dec 2018, 08:47

Did you understand why? Look at the closing curly brackets!
I suggest to change the indentation scheme you use.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], inseption86, just me, metallizer, Rohwedder and 178 guests