When i use the Menu command to create context menus is there a way i can get the menus and iterate over the menu items for example to list them or save them?
The way i do it now is to store the same data in a colletion when i add them to a menu, but if the menus are available then i wouldnt have to do that.
Getting menus as objects
Re: Getting menus as objects
Sure, if your script creates the menu, then you know what the menu items are. You can use a loop to create or save any of the items.
Re: Getting menus as objects
If you don't keep track, it would take extra work. Below is some information.
https://autohotkey.com/board/topic/39011-how-to-get-popup-menu-items/
https://autohotkey.com/board/topic/39011-how-to-get-popup-menu-items/
Each menu item is assigned an ID when it is first added to the menu. Scripts cannot rely on an item receiving a particular ID, but can retrieve the ID of an item by using GetMenuItemID as shown in the MenuGetHandle example. This ID cannot be used with the Menu command, but can be used with various Win32 functions.
Re: Getting menus as objects
Thanks! Yeah i already decided i want to keep track on them myself because i will probably want to add metadata further on. But i remainded curious.mikeyww wrote: ↑16 Nov 2020, 15:16If you don't keep track, it would take extra work. Below is some information.
https://autohotkey.com/board/topic/39011-how-to-get-popup-menu-items/
Each menu item is assigned an ID when it is first added to the menu. Scripts cannot rely on an item receiving a particular ID, but can retrieve the ID of an item by using GetMenuItemID as shown in the MenuGetHandle example. This ID cannot be used with the Menu command, but can be used with various Win32 functions.