How can I remove item form menu?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Marcosa1020
Posts: 168
Joined: 23 Sep 2015, 19:15

How can I remove item form menu?

Post by Marcosa1020 » 28 Jan 2022, 19:46

Hi,
How can I remove the "Suspend Hotkeys" and "Pause Script" from the menu?
i.PNG
i.PNG (5.2 KiB) Viewed 498 times

User avatar
mikeyww
Posts: 26591
Joined: 09 Sep 2014, 18:38

Re: How can I remove item form menu?

Post by mikeyww » 28 Jan 2022, 19:58

Remove the standard menu, and then create your own. https://www.autohotkey.com/docs/commands/Menu.htm#NoStandard

User avatar
JoeWinograd
Posts: 2177
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: How can I remove item form menu?

Post by JoeWinograd » 28 Jan 2022, 20:06

Hi @Marcosa1020,

You can do Menu,Tray,NoStandard and then add whatever menu items you want. For example, here's a context menu that I use in some of my scripts:

Code: Select all

Menu,Tray,NoStandard ; remove standard system tray context menu
Menu,Tray,Add,&About (and Pause),ContextMenu ; first menu item is About (A is keyboard shortcut key)
Menu,Tray,Add,E&xit,ContextMenu ; second menu item is Exit (X is keyboard shortcut key)
Menu,Tray,Default,&About (and Pause) ; default on double-click
Regards, Joe

teadrinker
Posts: 4309
Joined: 29 Mar 2015, 09:41
Contact:

Re: How can I remove item form menu?

Post by teadrinker » 28 Jan 2022, 21:23

Menu items can be removed directly:

Code: Select all

#Persistent
hMenu := MenuGetHandle("Tray")
Loop 2
   DllCall("RemoveMenu", "Ptr", hMenu, "UInt", 7, "UInt", MF_BYPOSITION := 0x400)

User avatar
JoeWinograd
Posts: 2177
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: How can I remove item form menu?

Post by JoeWinograd » 29 Jan 2022, 00:25

Hi teadrinker,
Very interesting! Thanks for posting. That said, I never let a script out the door without my own, custom tray menu. :) Cheers, Joe

Post Reply

Return to “Ask for Help (v1)”