Check all or clear all checkboxes

Get help with using AutoHotkey and its commands and hotkeys
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

13 Dec 2018, 08:54

Yeah, i've seen it.... the 2nd } was giving the problem right?
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Check all or clear all checkboxes

13 Dec 2018, 09:05

correct.

If you like, let me show you something else too. It is in the realm of structuring code.

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
        Delete_people_icon()

    if Folder_options = 1
        Folder_options()
}

Delete_people_icon() {
    ;~ 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
}

Folder_options()  {
    ;~ 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
}
The idea is: write short, bite-sized blocks of code.
Here, I "abstacted/extracted" the top-level logic from the whole.
And all the pieces come together nicely afterwards. Take advantage of more structure, so to speak ..

PS: I hope to make sense
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

13 Dec 2018, 09:18

Aha nice ! well i see this could be more structured... but when i tried this, i encounter a problem...... anyway, i am glad with the latest script

i already add a 4th tab for more dangerous registries (for personal use only)

Do you want to see it when it's done?
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

13 Dec 2018, 10:09

Ok, the main script is done with 4 tabs in total...

for as i can see all scripts are working

for this i disabled the regwrite and all the runs
Win10 Tweaks.zip
(10.68 KiB) Downloaded 43 times
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Check all or clear all checkboxes

13 Dec 2018, 10:24

Very nice! :thumbup:

You now need to update the WinTitle to read "Installatiemenu dec 2018"!
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

13 Dec 2018, 10:32

Hm? The title IS Installatiemenu nov 2018.......

a few seconds later........

oh haahahaha, yep indeed !

Thanx for all the help! Couldn't do it without you!
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

15 Dec 2018, 16:36

I overlooked 1 huge thing:

Now i have 2 columns on every tab except 1... The 'settings' tab which is one column only..... i like to have 2 or maybe 3 columns, i examend the Win10 Tweaks.ahk but it's too difficult for me to change al of the neccessary entries, i asume only the Win10 Tweaks.ahk has to be changed from the point where it says:

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

Can you help me with that? i dont have to have to select all or none because it has to remain clickable (no checkboxes) so everything stays the same, just the columns.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Check all or clear all checkboxes

15 Dec 2018, 16:47

Yes, sure. Looks like you already located the correct method of the class that needs to change. I will check what can be done, 2 columns should be possible, maybe even more.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Check all or clear all checkboxes

15 Dec 2018, 16:57

Try this for 2 columns:

Code: Select all

    AddText(ByRef Box) { ; populate tab with text
        local pos := (Box[3] & 1) ; flip even/odd
            ? "yp x" this.Tab_Width // 2    ; 2, 4, 6, 8, ...
            : "y+3 xs"                      ; 1, 3, 5, 7, ...
        Gui, Add, Text, % pos Box[1], % Box[2]
    }
I changed the name of the parameter from Ctrl to Box, to match with the other 2 columns function
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

15 Dec 2018, 18:40

Awsome! how a few lines of script can make some very happy.......... ME!

Thanx mate !
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

23 Sep 2019, 07:08

Hi there foks and especially greetings to wolf_II , i would like to ask a question about this script

I would like to have an extra line (just a seperation between two lines (see example 1)

Also i would like to have an 4 columns instead of 2, which gives me the option to undo a reg entry (see example 2) or just a text next to the registry line or checkbox

Here is the script (which is heavily stripped because of privacy and to play with without doing anything on your system

Code: Select all

#NoEnv
#SingleInstance Force

    new Menu("Test Installation Menu -= December 2018 - September 2019 =-")
    .Layout("Programs")
    .Tab_Size(900, 700)
    .Show(400, 50)

return ; end of auto-execute section

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
    }

    
    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%
        Gui, Show, center
    }

    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
        }

    }

}

Programs() {
    new Menu.Page(Title := "Installation and shortcuts", "Start_Programs")
	.AddCheckbox( 0, "wnetwatcher", "Wireless Network Watcher (1Mb)")
		.AddCheckbox( 0, "ammyy", "Ammyy (1Mb)")
	.AddCheckbox( 0, "rufus", "Rufus (2Mb)")
		.AddCheckbox( 0, "ultraviewer", "Ultraviewer 6.2 (3Mb)")
	.AddCheckbox( 0, "PartitionWizard11", "MiniTool Partition Wizard 11 (30Mb)")
		.AddCheckbox( 0, "chromeportable", "Portable Chrome (70Mb)")
	.AddCheckbox( 0, "EpsonXP630", "* Drivers - Epson XP-630 (64Mb)")
    return Title
}

Start_Programs() {
    global
    Gui, Submit, NoHide

	 if wnetwatcher = 1
	{
 ; start something
	}

	 if chromeportable = 1
	{
 ; start something
	}

	 if rufus = 1
	{
 ; start something
	}

	 if ammyy = 1
	{
 ; start something
	}

	 if ultraviewer = 1
	{
 ; start something
	}

	 if EpsonXP630 = 1
	{
 ; start something
	}

	 if PartitionWizard11 = 1
	{
 ; start something
	}
}
return


Attachments
ahk_undo.png
undo reg entry
ahk_undo.png (54.59 KiB) Viewed 1516 times
ahk_sep.png
seperator
ahk_sep.png (38.13 KiB) Viewed 1516 times
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: Check all or clear all checkboxes

29 Sep 2019, 06:59

orry for the delayed response. I suggest this code:

Code: Select all

Programs() {
    new Menu.Page(Title := "Installation and shortcuts", "Start_Programs")
	.AddCheckbox( 0, "wnetwatcher", "Wireless Network Watcher (1Mb)")
		.AddCheckbox( 0, "ammyy", "Ammyy (1Mb)")
	.AddCheckbox( 0, "rufus", "Rufus (2Mb)")
		.AddCheckbox( 0, "ultraviewer", "Ultraviewer 6.2 (3Mb)")
	.AddCheckbox( 0, "PartitionWizard11", "MiniTool Partition Wizard 11 (30Mb)")
		.AddCheckbox( 0, "_", "_______________________")
	.AddCheckbox( 0, "EpsonXP630", "* Drivers - Epson XP-630 (64Mb)")
		.AddCheckbox( 0, "chromeportable", "Portable Chrome (70Mb)")
    return Title
}
to get an extra line (example 1). I hope that helps. In case you dislike the looks of it, we need to think about something else.

2) About that registry-do / registry-undo:
I remember some "windows-scripting-guy" software which went something like this:

First the script reads from registry looking for a particular setting. (say e.g. Privacy settings in Win10: Disallow Cortana to listen to your microphone and upload to MS server by default)
If "DesiredSetting" was found, present an option to make "DefaultSetting" happen (undo),
else: present an option to make "DesiredSetting" happen (do).

I don't get yet where 4 columns come in useful here. Would it be an option to review/rewrite the corresponding page to say clearly what is the default, as well as saying clearly what happens when "DesiredSetting" is chosen. Currently, a click on "Wireless Network Watcher" will change color and set or delete the tick mark. Why 4 columns?

I looked at O&OSU10.exe. It seems to me: One option to switch on/off is sufficient, The thing to do here is: provide enough and CLEAR information for the user to decide which way to go. In other words: don't split these pages into columns, for those pages, use the full width to inform the user.
Rather than splitting into two columns, split into multiple pages...

I might very well be misunderstanding your goal, sorry
loek3000
Posts: 146
Joined: 12 Nov 2013, 03:24

Re: Check all or clear all checkboxes

07 Nov 2019, 17:40

Sorry wolf_II for the VERY late reaction, alot of personal things are going on while i'm writing this aswell..
And i also didnt get any notification about replies, i enabled it now...

To answer your questions:

The extra line is not very 'good looking' it feels like something is missing with the checkbox still there...

2 yeah i know about the read registry option and react to it on ahk (i know it's possible but i dont know how)
i can make an reg /e to a temp folder when executing an registry change and make another tab for uninstalling the changes, so that might be an option, what do you think?

I would like to have it, when the scripts starts, it already knows what scripts are already writtin, so the checkbox is a filled box, not checked and not empty, hope you understand what i am saying.

The tab thing, you are absolutly right, 2 tabs are more then enough to work with.... also you said about to inform the user with enough information.

For right now i'm having 8! tabs (see screenshot)

But i have 1 desire to change and i really hope i am clear enough what i am trying to say (the english language is not my main)

For this i stripped the script so it's more clear:

Now the total script is:

Code: Select all

#NoEnv
#SingleInstance Force

    new Menu("DONT WORRY ALL SCRIPTS ARE DISABLED")
    .Layout( "Advanced_Registry")
    .Tab_Size(1100, 700)
    .Show(400, 50)

return ; end of auto-execute section

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 Box) { ; populate tab with text
        local pos := (Box[3] & 1) ; flip even/odd
            ? "yp x" this.Tab_Width // 2    ; 2, 4, 6, 8, ...
            : "y+3 xs"                      ; 1, 3, 5, 7, ...
        Gui, Add, Text, % pos Box[1], % Box[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, Arial

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

        Gui, Show, center
    }

    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
        }
    }
}

Advanced_Registry() {
    new Menu.Page(Title := "• Registry", "Start_Advanced_Registry")
   .AddCheckbox( 1, "SearchboxTaskbarMode", "Disable search bar on taskbar")
   .AddCheckbox( 1, "Remove_intel_context_menu", "Remove Intel entries from context menu")
   .AddCheckbox( 1, "Disable_grouping", "Disable grouping with open windows on taskbar")
   .AddCheckbox( 1, "kleuren_en_afstanden_en_tranparanties_1", "DPI FIX - No blurry fonts anymore")
   .AddCheckbox( 1, "Update_context_menu", "Add Update at the top off context menu")
   .AddCheckbox( 1, "Remove_shortcut_arrow", "Remove shortcut arrow from desktop")
   .AddCheckbox( 0, "Icon_distance", "Shorten distance between icons on desktop")
   .AddCheckbox( 0, "kleuren_afstanden_tranparanties", "Change color active and inactive windows")
   .AddCheckbox( 0, "DisableShowTaskViewButton", "Disable Taskview Button")
   .AddCheckbox( 0, "Snelle_toegang", "Personal Quick Access on the left window panel")
   return Title
}
Start_Advanced_Registry() {
    global
    Gui, Submit, NoHide
	  if SearchboxTaskbarMode = 1
	{
MsgBox Just for testing
	}
	  if Remove_intel_context_menu = 1
	{
MsgBox Just for testing
	}
	  if Disable_grouping = 1
	{
MsgBox Just for testing
	}
	  if kleuren_en_afstanden_en_tranparanties_1 = 1
	{
MsgBox Just for testing
	}
	  if Update_context_menu = 1
	{
MsgBox Just for testing
	}
	 if Remove_shortcut_arrow = 1
	{
MsgBox Just for testing
	 }
          if Icon_distance = 1
	{
MsgBox Just for testing
	}
	  if DisableShowTaskViewButton = 1
	{
MsgBox Just for testing
	}
	  if kleuren_afstanden_tranparanties = 1
	{
MsgBox Just for testing
	}
          if Snelle_toegang = 1
	{
MsgBox Just for testing
	}
}
return
Result is at now.png screenshot.


When i add more items to :

.AddCheckbox( 1, "SearchboxTaskbarMode", "Disable search bar on taskbar")
.AddCheckbox( 1, "Remove_intel_context_menu", "Remove Intel entries from context menu")
.AddCheckbox( 1, "Disable_grouping", "Disable grouping with open windows on taskbar")
.AddCheckbox( 1, "kleuren_en_afstanden_en_tranparanties_1", "DPI FIX - No blurry fonts anymore")
.AddCheckbox( 1, "Update_context_menu", "Add Update at the top off context menu")
.AddCheckbox( 1, "Remove_shortcut_arrow", "Remove shortcut arrow from desktop")
.AddCheckbox( 0, "Icon_distance", "Shorten distance between icons on desktop")
.AddCheckbox( 0, "kleuren_afstanden_tranparanties", "Change color active and inactive windows")
.AddCheckbox( 0, "DisableShowTaskViewButton", "Disable Taskview Button")
.AddCheckbox( 0, "Snelle_toegang", "Personal Quick Access on the left window panel")

the entries are lined up from left to right, in other words: 1st line is on the left, 2nd line is on the right. I rather have the lines like there are here, but also in the gui result.
So now:
disable search is on the left and remove intel... is on the right
i prefer to have it that i fill up the lines in the script and on the gui it fills up from the left till the gui max height is full and the gui shows the entries after that to the next column. It makes it easier to write the entries and know on forehand what the gui result will be.....

I would like to have 'sections' in this script, like : 'interface' 'tweaks' 'context menu' but i know that would be a totaly other script and everything changes. But on the other hand, if it was, it wouldn't be an problem to have tabs instead of columns with better layout and more information.

So sorry again for the VERY late reaction on this, hope you can still help me
Attachments
total.png
total.png (75.92 KiB) Viewed 1208 times
now.png
now.png (27.18 KiB) Viewed 1208 times
loek6000
Posts: 36
Joined: 14 Aug 2019, 17:46

Re: Check all or clear all checkboxes

08 Nov 2019, 05:03

This is my new nick...

What i meant by a different layout is like this:
Attachments
Untitled-1.jpg
Untitled-1.jpg (49.18 KiB) Viewed 1155 times

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], mikeyww, SimmoF and 30 guests