Jump to content

Recommended Posts

Posted

The Help says:

  Quote

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.

  Reveal hidden contents

 

  • Moderators
Posted

c.haslam,

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")
TrayCreateItem("")
$hTray_Item_2 = TrayCreateItem("2")
TrayItemSetState($hTray_Item_2, $TRAY_DEFAULT)
TrayItemSetOnEvent(-1, "On_2")

TraySetState()

While 1
    Sleep(10)
WEnd

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

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

Func On_Exit()
    Exit
EndFunc

M23

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:

  Reveal hidden contents

 

Posted

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

  Quote

'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.

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...