DrLarch Posted January 21, 2016 Share Posted January 21, 2016 I'm sure this must be simple, but I'm not figuring it out. I want to have an action tied to clicking with the primary mouse button on the tray icon, and have a menu show only if clicking with the secondary button. I'm playing with the example from TraySetOnEvent in the help file. The way it is here, the menu shows up regardless of primary or secondary click: #NoTrayIcon #include <MsgBoxConstants.au3> #include <TrayConstants.au3> ; Required for the $TRAY_EVENT_PRIMARYDOUBLE, $TRAY_EVENT_SECONDARYUP and $TRAY_ICONSTATE_SHOW constants. Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode. Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode. Example() Func Example() TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "ExitScript") TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "TrayEvent") TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu. While 1 Sleep(100) ; An idle loop. WEnd EndFunc ;==>Example Func TrayEvent() Switch @TRAY_ID ; Check the last tray item identifier. Case $TRAY_EVENT_PRIMARYUP ; Display a message box about the AutoIt version and installation path of the AutoIt executable. MsgBox($MB_SYSTEMMODAL, "Title", "Text") EndSwitch EndFunc ;==>TrayEvent Func ExitScript() Exit EndFunc ;==>ExitScript I've tried adding a Case $TRAY_EVENT_SECONDARYUP event to the TrayEvent(), and generating the menu there but that doesn't work correctly. The Example() function is obviously where the menu should be setup, but how does one control under what condition (primary or secondary click) the menu actually appears? Link to comment Share on other sites More sharing options...
TheSaint Posted January 22, 2016 Share Posted January 22, 2016 (edited) I haven't tried to do this myself, and are not currently setup to do so, but have you played around with TrayGetMsg ? Seems to me that the key to what you want is there. Edited January 22, 2016 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
DrLarch Posted January 22, 2016 Author Share Posted January 22, 2016 Thanks Saint, but I'm still not able to get it to do what I want via TrayGetMsg. If I generate the menu with TrayCreateItem under Case $TRAY_EVENT_SECONDARYUP then it appears on subsequent left clicks also. I've tried using TrayItemDelete to get rid of the menu under Case $TRAY_EVENT_PRIMARYUP, but that doesn't work either. Does anybody have code that shows the tray menu under secondary click only? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 24, 2016 Moderators Share Posted January 24, 2016 DrLarch, You need TraySetClick - look in the Help file for more details. M23 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...
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