Jump to content
Sign in to follow this  

What does TrayMenuMode 4 do?

Recommended Posts

The Help says:

4 = don't return the menuitemID which has the "default"-style in the main contextmenu if you double click the tray icon

Would someone please explain what this means, perhaps with an example.

It has taken me a long time to figure out how to write good code for the Tray menu, so I would like to contribute a clear explanation.


CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard


Share this post

Link to post
Share on other sites


somdcomputerguy is absolutely correct, as this short script shows (just comment/uncomment the different Opt("TrayMenuMode" lines to see the difference): :graduated:

#include <Constants.au3>

Opt("TrayOnEventMode", 1) ; Use event trapping for tray menu

Opt("TrayMenuMode", 3) ; Default tray menu items will not be shown and no tick marks.
;Opt("TrayMenuMode", 7)

HotKeySet("{ESC}", "On_Exit")

$hTray_Item_1 = TrayCreateItem("1")
TrayItemSetOnEvent(-1, "On_1")
$hTray_Item_2 = TrayCreateItem("2")
TrayItemSetState($hTray_Item_2, $TRAY_DEFAULT)
TrayItemSetOnEvent(-1, "On_2")


While 1

Func On_1()
    ConsoleWrite("1" & @CRLF)

Func On_2()
    ConsoleWrite("2" & @CRLF)

Func On_Exit()


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites

Thank you, both. Now it makes sense. I will post my proposed doc for Tray... for comments and suggestions when I think I have it correct. I am a little frustrated by the way AutoIt help is set up: function by function, with one big Opt page. The best I can think of is to propose clear, concise explanations which would go in the TrayCreateItem page, and amplify TrayMenuMode in the Opt page.

Whether the menuradioitem parameter of TrayCreateItem is used or ignored depends on the TrayMenuMode. Perhaps bRadioOrCheck (or fRadioOrCheck) would be a better name.

Re menuentry: The help says that the default is to add an item

'behind' the last created entry

. "Behind" looks odd to me. The default seems to be to add items in the order they are in the code.

Perhaps if there are items with menuentry 100 and 200, adding one with menuentry 150 might insert this item between 100 and 200. I haven't tried it. If so, nItemPos (or some such) might be a better name for the parameter

Am I correct in thinking that one always codes #NoTrayIcon when one has a Tray user menu? All the examples in the Help seem to start with #NoTrayIcon.


CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...