How to delete all menus at once?

Get help with using AutoHotkey and its commands and hotkeys
m3user
Posts: 147
Joined: 17 Jan 2014, 18:11

How to delete all menus at once?

17 Jan 2014, 18:22

Hello everyone,

I'm using a Menu command to create menus from folders and files which is changed dynamically many times. The problem is that after adding new submenus, the old ones are not deleted. I understand I should first delete every menu and submenu before adding new ones but currently I'm not keeping the track of the names of all submenus etc.

I want to completely recreate a menu every time. Is there a way to simply delete all the menus at once? Any idea how to do this? Thank you.
HelpQuote

Re: How to delete all menus at once?

18 Jan 2014, 02:40

Delete [, MenuItemName]: Deletes MenuItemName from the menu. Standard menu items such as Exit (see below) cannot be individually deleted. If the default menu item is deleted, the effect will be similar to having used the NoDefault option. If MenuItemName is omitted, the entire MenuName menu will be deleted as will any menu items in other menus that use MenuName as a submenu.
m3user
Posts: 147
Joined: 17 Jan 2014, 18:11

Re: How to delete all menus at once?

18 Jan 2014, 05:52

Thanks but this is not a solution as it does not delete submenus.

As I said I don't save submenus names so I don't know how to delete them all.
Zelio
Posts: 275
Joined: 30 Sep 2013, 00:45
Location: France

Re: How to delete all menus at once?

18 Jan 2014, 07:10

About internal autohotkey menu, it is Menu, MyMenu, DeleteAll, else go to http://msdn.microsoft.com/en-us/library ... 68865.aspx
Warning: Hotkeys don't work when your menu is shown, Labels created for menu will still there, ...

Code: Select all

Menu, MyMenu, Add, Item1, MenuHandler
Menu, MyMenu, Add, Item2, MenuHandler
Menu, MyMenu, Add 
Menu, Submenu1, Add, Item1, MenuHandler
Menu, Submenu1, Add, Item2, MenuHandler
Menu, MyMenu, Add, My Submenu, :Submenu1
Menu, MyMenu, Add
Menu, MyMenu, Add, Item3, MenuHandler
return

MenuHandler:
tooltip You selected %A_ThisMenuItem% from the menu %A_ThisMenu%.
return

~LButton::
Menu, MyMenu, Show
return

~r::
Menu, MyMenu, Add, recreatedItem1, MenuHandler
Menu, MyMenu, Add, Item2, MenuHandler
return

~d::
Menu, MyMenu, DeleteAll
return

esc::
exitapp
m3user
Posts: 147
Joined: 17 Jan 2014, 18:11

Re: How to delete all menus at once?

18 Jan 2014, 07:29

Thanks, DeleteAll doesn't work either.

Please see the following example. You can see that SubItem1 is still there after recreating a menu. Is there any other way? Unfortunately I don't know how to use dll or similar commands. Thanks.

Code: Select all

Menu, Submenu1, Add, SubItem1, MenuHandler
Menu, MyMenu, Add, Item1, :Submenu1
Menu, MyMenu, Show 

msgbox Creating a new Menu
Menu, MyMenu, DeleteAll

Menu, Submenu1, Add, NewSubItem1, MenuHandler
Menu, MyMenu, Add, NewItem1, :Submenu1
Menu, MyMenu, Show 
Return

MenuHandler:
return
Zelio
Posts: 275
Joined: 30 Sep 2013, 00:45
Location: France

Re: How to delete all menus at once?

18 Jan 2014, 11:28

Hmm, if you know that you will recreate a "SubMenu1" then start to delete it...

Code: Select all

Menu, Submenu1, Add, SubItem1, MenuHandler
Menu, MyMenu, Add, Item1, :Submenu1
Menu, MyMenu, Show

msgbox Creating a new Menu

; Menu, Iwillcreatethismenu, DeleteAll
; Menu, Iwillcreatethismenu, Add, NewSubItem1, MenuHandler
Menu, Submenu1, DeleteAll
Menu, Submenu1, Add, NewSubItem1, MenuHandler
Menu, MyMenu, DeleteAll
Menu, MyMenu, Add, NewItem1, :Submenu1
Menu, MyMenu, Show

MenuHandler:
return

Return to “Ask For Help”

Who is online

Users browsing this forum: bobkater, BreezeB, Google [Bot], Gully, miike, Sam_ and 201 guests