|
; AutoHotKey Multi Column Menu Example |
|
; Forum URL - https://autohotkey.com/board/topic/69553-menu-with-columns-problem-with-adding-column-separator/#entry440866 |
|
; https://autohotkey.com/board/topic/25008-multi-column-menu/ |
|
; GitHub Gist URL - https://gist.github.com/jasondavis/d5d3e8437241c27d99f583259484f667 |
|
;- File Path - |
|
; Image - https://www.apollowebstudio.com/screenshots/2018/04/2018-04-01_01-13-01.png |
|
|
|
|
|
Menu, main, Add, Item 1, MenuHandler |
|
Menu, main, Add, Item 2, MenuHandler |
|
Menu, main, Add, Item 3, MenuHandler |
|
Menu, main, Add, Item 4, MenuHandler |
|
Menu, main1, Add, SubItem 1, MenuHandler |
|
Menu, main1, Add, SubItem 2, MenuHandler |
|
Menu, main1, Add, SubItem 3, MenuHandler |
|
Menu, main, Add, Submenu1, :main1 |
|
Menu, main, Add, Item 5, MenuHandler |
|
|
|
MenuHandle := GetMenuHandle( "main" ) |
|
|
|
/* |
|
VarSetCapacity(mii,48,0) |
|
NumPut(48,mii) |
|
NumPut(0x10,mii,4) ; fMask = MIIM_TYPE |
|
NumPut(0x160,mii,8) ; fType = RGB_VERTICALBARBREAK |
|
DllCall("InsertMenuItem","uint",MenuHandle,"uint",2,"uint",1,"uint",&mii) |
|
*/ |
|
|
|
VarSetCapacity(mii, cb:=16+8*A_PtrSize, 0) ; A_PtrSize is used for 64-bit compatibility. |
|
NumPut(cb, mii, "uint") |
|
NumPut(0x100, mii, 4, "uint") ; fMask = MIIM_FTYPE |
|
NumPut(0x20, mii, 8, "uint") ; fType = MFT_MENUBARBREAK |
|
|
|
; "4" below is the menu item to start on a new column |
|
DllCall("SetMenuItemInfo", "ptr", MenuHandle, "uint", 2, "int", 1, "ptr", &mii) |
|
DllCall("SetMenuItemInfo", "ptr", MenuHandle, "uint", 4, "int", 1, "ptr", &mii) |
|
#m::menu, main, show |
|
|
|
MenuHandler: |
|
msgbox, Menu: %A_ThisMenu%, item: %A_ThisMenuItemPos% |
|
return |
|
|
|
GetMenuHandle(menu_name) ;from MenuIcons v2 |
|
{ |
|
static h_menuDummy |
|
; v2.2: Check for !h_menuDummy instead of h_menuDummy="" in case init failed last time. |
|
If !h_menuDummy |
|
{ |
|
Menu, menuDummy, Add |
|
Menu, menuDummy, DeleteAll |
|
|
|
Gui, 99:Menu, menuDummy |
|
; v2.2: Use LastFound method instead of window title. [Thanks animeaime.] |
|
Gui, 99:+LastFound |
|
|
|
h_menuDummy := DllCall("GetMenu", "uint", WinExist()) |
|
|
|
Gui, 99:Menu |
|
Gui, 99:Destroy |
|
|
|
; v2.2: Return only after cleaning up. [Thanks animeaime.] |
|
if !h_menuDummy |
|
return 0 |
|
} |
|
|
|
Menu, menuDummy, Add, :%menu_name% |
|
h_menu := DllCall( "GetSubMenu", "uint", h_menuDummy, "int", 0 ) |
|
DllCall( "RemoveMenu", "uint", h_menuDummy, "uint", 0, "uint", 0x400 ) |
|
Menu, menuDummy, Delete, :%menu_name% |
|
|
|
return h_menu |
|
} |