Hello,
I would like to write a menu with submenus.
The selection of the menu item should be done via the keyboard.
Example:
Menu: 1_Links , Submenu: 1_1_Internet_Links, 1_2_Server_Links.
Menu: 2_Outputs , Submenu: 2_1_Text_field1, 2_2_Text_field2
After calling the menu, I want to press a 2 on the numeric keypad to get to the menu item 2_Outputs and another 2 to get to the submenu item: 2_2_TextField2.
I want to create more than 100 menu items and there every keystroke is one too many if it can be avoided.
Select menu items via keyboard
Re: Select menu items via keyboard
Welcome to this AutoHotkey forum!
The easy way is to prepend the menu text with your keyboard shortcut, such as 1-Item 1. Actually, that's the only way I know (perhaps aside from running a separate script), but others here may have some better tricks.
You could run a separate script just for handling the menu shortcuts.
The easy way is to prepend the menu text with your keyboard shortcut, such as 1-Item 1. Actually, that's the only way I know (perhaps aside from running a separate script), but others here may have some better tricks.
You could run a separate script just for handling the menu shortcuts.
- flyingDman
- Posts: 2824
- Joined: 29 Sep 2013, 19:01
Re: Select menu items via keyboard
Code: Select all
#Requires AutoHotkey v2.0
MyMenu := Menu()
Submenu1 := Menu()
SubSubmenu1 := Menu()
SubSubMenu1.add "&1 Google 1_1_1", MenuHandler
SubSubMenu1.add "&2 Bing 1_1_2", MenuHandler
Submenu1.Add "&1 InternetLinks", SubSubMenu1
Submenu1.Add "&2 ServerLinks 1_2", MenuHandler
MyMenu.Add "&1 Links ", Submenu1
Submenu2 := Menu()
Submenu2.Add "&1 Textfield1 2_1", MenuHandler
Submenu2.Add "&2 Textfield2 2_2", MenuHandler
MyMenu.Add "&2 Outputs", Submenu2
F12::MyMenu.Show ; launch the menu
MenuHandler(Item, *)
{
MsgBox(substr(Item,instr(Item," ")),"Menu","T2") ; use switch
}
14.3 & 1.3.7
Re: Select menu items via keyboard
You can also run multiple AHK files to pop up multiple menus.