3 rows instead of just 2

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
loek6000
Posts: 164
Joined: 14 Aug 2019, 17:46

3 rows instead of just 2

Post by loek6000 » 13 Oct 2022, 01:44

wolf_II helped me alot with this, all credit goes mainly to him. I really dont know how to make scripts, so i have to be honest, i need help because i myself can't do it.

Years ago this was made. It has two rows of checkboxes or lines of script

Main question: how can i add a 3rd row instead of 2 like it is now:

Code: Select all

#SingleInstance Force

    new Menu("Menu")
    .Layout( "Registry1")
    .Tab_Size(1300, 700)
    .Show(400, 50)
return

GuiClose:
ExitApp
class Menu {
    static Children := {} ;}
    Tab_Width   := A_ScreenWidth // 2
    Tab_Height  := A_ScreenHeight // 2
    Tab_List    := ""
    __New(WinTitle) {
        Gui, Menu: New, LabelGui, %WinTitle%
	        Gui, Font, s11, Segoe UI
    }
    Layout(args*) {
        Loop, % args.length() ; FName = also name of #Include-files
            FName := args[A_Index], _List .= "|" %FName%()
        this.Tab_List := LTrim(_List, "|")
        return this
    }
    Tab_Size(w, h) {
        this.Tab_Width := w
        this.Tab_Height := h
        return this
    }
    AddText(ByRef Box) {
        local pos := (Box[3] & 1)
            ? "yp x" this.Tab_Width // 2
            : "y+3 xs"
        Gui, Add, Text, % pos Box[1], % Box[2]
    }
    AddCheckbox(ByRef Box) {
        local pos := (Box[4] & 1)
            ? "yp x" this.Tab_Width // 2
            : "y+3 xs"
        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) {
        GuiControlGet, State,, %hWnd%
        GuiControl, % "+c" (State ? "Green" : "Red"), %hWnd%
    }
    AddTab(i, ByRef Child) {
        Gui, Tab, %i%
        if (Child.Boxes.Length()) {
            Gui, Add, Button, HWNDhAll Section, ALLES selecteren
            Gui, Add, Button, HWNDhNone x+m, NIETS selecteren
	    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() {
        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() {
        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") {
        w := this.Tab_Width, h := this.Tab_Height
        Gui, Add, Tab2, w%w% h%h%, % this.Tab_List
        Gui, Font, s10, Segoe UI
        for i, Child in this.Children
            this.AddTab(i, Child)
Gui, Color, % GuiColor := "ffffff"
	Gui, Show, center
    }
    class Page {
        Title    := ""
        CallBack := ""
        VarNames := []
        Boxes    := []
        Texts    := []
        __New(Title, CallBack := "") {
            this.Title := Title
            this.CallBack := CallBack
            Menu.Children.Push(this)
        }
        AddCheckbox(Flag, VarName, Text) {
            this.VarNames.Push(VarName)
            this.Boxes.Push([Flag, VarName, Text, this.Boxes.Length()])
            return this
        }
        AddText(Options, Text) {
            this.Texts.Push([Options, Text, this.Texts.Length()])
            return this
        }
    }
}

Registry1() {
    new Menu.Page(Title := " Its a tab", "Start_Registry1")
    .AddCheckbox( 1, "scripta",					"some description")
    .AddCheckbox( 1, "scriptb",					"some description")
    .AddCheckbox( 1, "scriptc",					"some description")
	return Title
}
return

Start_Registry1() {
    global
    Gui, Submit, NoHide

	if scripta = 1
	{
	msgbox hi harmless
	}

	if scriptb = 1
	{
	msgbox whats up
	}

	if scriptc = 1
	{
	msgbox close me
	}
}
return
Last edited by loek6000 on 15 Oct 2022, 02:41, edited 2 times in total.

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: 3 rows instead of just 2

Post by mikeyww » 13 Oct 2022, 06:55

Code: Select all

    AddCheckbox(ByRef Box) {
        local pos := (Box[4] & 1)
            ? "yp x" this.Tab_Width // 2
            : "y+3 xs"
        pos := "y+3 xs"
        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
    }

loek6000
Posts: 164
Joined: 14 Aug 2019, 17:46

Re: 3 rows instead of just 2

Post by loek6000 » 13 Oct 2022, 09:03

Well that results in a 1 row list
mikeyww wrote:
13 Oct 2022, 06:55

Code: Select all

    AddCheckbox(ByRef Box) {
        local pos := (Box[4] & 1)
            ? "yp x" this.Tab_Width // 2
            : "y+3 xs"
        pos := "y+3 xs"
        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
    }
Last edited by loek6000 on 15 Oct 2022, 01:27, edited 1 time in total.

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: 3 rows instead of just 2

Post by mikeyww » 13 Oct 2022, 09:52

The idea is that the function is called to add a checkbox (I think), and you can use GUI positioning parameters to position the control.

What my adjustment does:
add a 3rd row instead of 2 like it is now

loek6000
Posts: 164
Joined: 14 Aug 2019, 17:46

Re: 3 rows instead of just 2

Post by loek6000 » 13 Oct 2022, 11:52

mikeyww wrote:
13 Oct 2022, 09:52
The idea is that the function is called to add a checkbox (I think), and you can use GUI positioning parameters to position the control.

What my adjustment does:
add a 3rd row instead of 2 like it is now
Thanks but this change doesnt work for this script and i don't know much about it, it's a complex script

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: 3 rows instead of just 2

Post by mikeyww » 13 Oct 2022, 12:29

The image that you posted shows three rows. That's about all that I can do to align with your request for three rows. Others may have some better ideas here.

RussF
Posts: 1311
Joined: 05 Aug 2021, 06:36

Re: 3 rows instead of just 2

Post by RussF » 13 Oct 2022, 12:58

I think the issue may be one of semantics. Could it be that the OP said they wanted 3 "rows", when in fact they wanted 3 "columns"?

(You can usually give a customer what they ask for, but it's seldom what they want.)

Russ

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: 3 rows instead of just 2

Post by mikeyww » 13 Oct 2022, 13:07

Could be, or could be that they wanted five rows, or three diagonals! :)

RussF
Posts: 1311
Joined: 05 Aug 2021, 06:36

Re: 3 rows instead of just 2

Post by RussF » 13 Oct 2022, 13:14

What clued me in was:
loek6000 wrote:Well that results in a 1 row list
when in fact it was a 1 column list.

We, as experienced coders, understand the critical difference between "rows" and "columns". Others don't. :?

Russ

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: 3 rows instead of just 2

Post by mikeyww » 13 Oct 2022, 13:20

Good thinking! Thanks.

loek6000
Posts: 164
Joined: 14 Aug 2019, 17:46

Re: 3 rows instead of just 2

Post by loek6000 » 13 Oct 2022, 16:07

@mikeyww & @RussF Englisch is not my main language & sometimes i get the two mixed up when i ask questions like this. And i was honest saying i do not much know about scripting.....

But I DO know the difference working with programs like Excel.

Anyway, you 2 are 'coders', so do you know the answer to my original question ? :p

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: 3 rows instead of just 2

Post by mikeyww » 13 Oct 2022, 16:24

Although it may take some time & attempts, with 100 posts, you have passed the novice stage :) and so may be able to learn a bit about positioning.

https://www.autohotkey.com/docs/commands/Gui.htm#PosSize

A general idea:

Code: Select all

Gui, Add, Button,, B1
Gui, Add, Button,, B2
Gui, Add, Button,, B3
Loop, 3 {
 GuiControlGet, hWnd, Hwnd, Button4
 If hWnd
  pos = x+100
 Gui, Add, Checkbox, %pos%, C%A_Index%
}
Gui, Show
x+n, y+n (where n is any number): An optional plus sign can be included to position a control relative to the right or bottom edge (respectively) of the control that was previously added.

loek6000
Posts: 164
Joined: 14 Aug 2019, 17:46

Re: 3 rows instead of just 2

Post by loek6000 » 14 Oct 2022, 01:12

Not really, mainly i asked questions because i don't know. To be honest i believe i am below novice.

Anyway this script is too complex for me and i think it's too complex to be able to help me with that eventhough all attempts, and for that i thank you.
mikeyww wrote:
13 Oct 2022, 16:24
Although it may take some time & attempts, with 100 posts, you have passed the novice stage :) and so may be able to learn a bit about positioning.

https://www.autohotkey.com/docs/commands/Gui.htm#PosSize

A general idea:

Code: Select all

Gui, Add, Button,, B1
Gui, Add, Button,, B2
Gui, Add, Button,, B3
Loop, 3 {
 GuiControlGet, hWnd, Hwnd, Button4
 If hWnd
  pos = x+100
 Gui, Add, Checkbox, %pos%, C%A_Index%
}
Gui, Show
x+n, y+n (where n is any number): An optional plus sign can be included to position a control relative to the right or bottom edge (respectively) of the control that was previously added.

User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: 3 rows instead of just 2

Post by mikeyww » 14 Oct 2022, 06:42

Another example is below.

Code: Select all

    AddCheckbox(ByRef Box) {
        local pos := (Box[4] & 1)
            ? "yp x" this.Tab_Width // 2
            : "y+3 xs"
        local pos := "yp x+m"
        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
    }

loek6000
Posts: 164
Joined: 14 Aug 2019, 17:46

Re: 3 rows instead of just 2

Post by loek6000 » 15 Oct 2022, 01:34

@mikeyww That results in 1 row with all of the checkboxes at one line next to each other.

I remember @wolf_II said it needed the script to be way more complex to be able to add a 3rd column and he suggested that a 2 column tab is more then enough to be able to explain what a registry change can do. I agreed with him but the script is only used by me, so i already know what it does.

Anyway i've notice the following the columns are pushed more together so a 3rd column can be added (i think) yet i dont know how, so i am at the dead end.

Code: Select all

    AddCheckbox(ByRef Box) {
        local pos := (Box[4] & 1)
            ? "yp x" this.Tab_Width // 3 ; less space between columns (originaly it was set to 2)
            : "y+0 xs"
        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
    }
mikeyww wrote:
14 Oct 2022, 06:42
Another example is below.

Code: Select all

    AddCheckbox(ByRef Box) {
        local pos := (Box[4] & 1)
            ? "yp x" this.Tab_Width // 2
            : "y+3 xs"
        local pos := "yp x+m"
        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
    }
ps: for readability i deleted all the screenshots

User avatar
boiler
Posts: 17390
Joined: 21 Dec 2014, 02:44

Re: 3 rows instead of just 2

Post by boiler » 15 Oct 2022, 05:39

loek6000 wrote: ps: for readability i deleted all the screenshots
That was a terrible thing to do. Now all the context is lost for what it originally looked like and the discussion that followed. Please don’t do that again.

In fact, what you really should do is add another picture showing what you want because I don’t see how anyone could know what you want at this point. You started by saying you wanted a third row, and when code was provided to do that, it was determined that you meant three columns instead. So now you were provided code that produces three columns, and you say that’s not what you want because they are next to each other in the same row (which is what three columns looks like). Please take the time to clearly describe what you want for the sake of those who are struggling to try to help you. Write it in your primary language and use google translate if writing in English is part of the issue.

loek6000
Posts: 164
Joined: 14 Aug 2019, 17:46

Re: 3 rows instead of just 2

Post by loek6000 » 15 Oct 2022, 10:43

Terrible? It was certainly not my attention.

I will redo the screenshot and place it here
boiler wrote:
15 Oct 2022, 05:39
loek6000 wrote: ps: for readability i deleted all the screenshots
That was a terrible thing to do. Now all the context is lost for what it originally looked like and the discussion that followed. Please don’t do that again.

In fact, what you really should do is add another picture showing what you want because I don’t see how anyone could know what you want at this point. You started by saying you wanted a third row, and when code was provided to do that, it was determined that you meant three columns instead. So now you were provided code that produces three columns, and you say that’s not what you want because they are next to each other in the same row (which is what three columns looks like). Please take the time to clearly describe what you want for the sake of those who are struggling to try to help you. Write it in your primary language and use google translate if writing in English is part of the issue.
Attachments
Snipaste_2022-10-15_17-46-21.png
Snipaste_2022-10-15_17-46-21.png (33.29 KiB) Viewed 793 times

Trigun
Posts: 41
Joined: 29 Mar 2017, 01:33

Re: 3 rows instead of just 2

Post by Trigun » 15 Oct 2022, 11:00

or another easy way is with paint show what u want as expected output :-D

loek6000
Posts: 164
Joined: 14 Aug 2019, 17:46

Re: 3 rows instead of just 2

Post by loek6000 » 15 Oct 2022, 11:35

i see i am not the only one not having english as main language :lol:
Trigun wrote:
15 Oct 2022, 11:00
or another easy way is with paint show what u want as expected output :-D

Trigun
Posts: 41
Joined: 29 Mar 2017, 01:33

Re: 3 rows instead of just 2

Post by Trigun » 15 Oct 2022, 12:54

loek6000 wrote:
15 Oct 2022, 11:35
i see i am not the only one not having english as main language :lol:
Trigun wrote:
15 Oct 2022, 11:00
or another easy way is with paint show what u want as expected output :-D
no u are wrong :-D
i have problem in my main language too :-D

Post Reply

Return to “Ask for Help (v1)”