c.haslam Posted September 13, 2011 Share Posted September 13, 2011 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. Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard Link to comment Share on other sites More sharing options...
somdcomputerguy Posted September 13, 2011 Share Posted September 13, 2011 I would read that as Double-clicking the TrayIcon does not execute the code assigned with the 'default' TrayMenuItem. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 13, 2011 Moderators Share Posted September 13, 2011 c.haslam, somdcomputerguy is absolutely correct, as this short script shows (just comment/uncomment the different Opt("TrayMenuMode" lines to see the difference): #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 EndFuncM23 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: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
c.haslam Posted September 15, 2011 Author Share Posted September 15, 2011 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. Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now