Split menu into columns Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Ecimeric
Posts: 130
Joined: 11 Jan 2017, 02:23

Split menu into columns

15 May 2021, 18:41

Code: Select all

global AssocArray := {}
Array := []
Loop, Read, menuitems.txt
    Array.Push(StrSplit(A_LoopReadLine, ";"))
for index, element in Array {
    Menu, MyMenu, Add, % element.2, Function
    AssocArray[element.2] := element.3
}
Menu, MyMenu, Show
How can I split my menu into columns if there are more than 15 items in the array?
Last edited by Ecimeric on 15 May 2021, 19:49, edited 2 times in total.
User avatar
mikeyww
Posts: 26853
Joined: 09 Sep 2014, 18:38

Re: Split menu into columns

15 May 2021, 18:50

Menu:
+Break [v1.1.23+]: The item begins a new column in a popup menu.
Ecimeric
Posts: 130
Joined: 11 Jan 2017, 02:23

Re: Split menu into columns

15 May 2021, 19:13

I know about Break, but cannot get beyond:

Code: Select all

if Array.MaxIndex > 15 {
    Menu, AutoHotkey, Add, % element.2, Function, Break
} else
    Menu, AutoHotkey, Add, % element.2, Function
User avatar
mikeyww
Posts: 26853
Joined: 09 Sep 2014, 18:38

Re: Split menu into columns  Topic is solved

15 May 2021, 19:34

Your script here is just a fragment and so cannot be tested. An example of a menu break is below.

Code: Select all

For index, element in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    Menu, menu1, Add, %element%, Function, % A_Index = 6 ? "+Break" : ""
Menu, menu1, Show

Function() {
}
Ecimeric
Posts: 130
Joined: 11 Jan 2017, 02:23

Re: Split menu into columns

15 May 2021, 19:58

Thank you; would it be just as straightforward to add a break after each nth item, instead of having n items in one column, and the balance in the next?
User avatar
mikeyww
Posts: 26853
Joined: 09 Sep 2014, 18:38

Re: Split menu into columns

15 May 2021, 21:03

I think so.

Code: Select all

breakEvery := 3
For index, element in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    Menu, menu1, Add, %element%, Function, % Mod(A_Index - 1, breakEvery) ? "" : "+Break"
Menu, menu1, Show

Function() {
}
Ecimeric
Posts: 130
Joined: 11 Jan 2017, 02:23

Re: Split menu into columns

15 May 2021, 21:41

Perfect, thank you :thumbup:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, Giresharu, Google [Bot], icyolive, inseption86, mikeyww, songdg, Swiftly9767 and 286 guests