gbrao Posted August 12, 2018 Share Posted August 12, 2018 I would like to display a different menu depending on whether the user has right- or left- clicked the tray icon. Is this possible with autoit? I was able to do it with autohotkey by modifing the code here : https://autohotkey.com/board/topic/11250-mouseover-trayicon-triggering-an-event/#entry153388 I prefer autoit, so I would like to develop the same (compiled) program in autoit. Link to comment Share on other sites More sharing options...
AutoBert Posted August 12, 2018 Share Posted August 12, 2018 Never tried this option (different traymenus) but as TrayGetMsg can recognize different clicks, i would say yes. Link to comment Share on other sites More sharing options...
gbrao Posted August 12, 2018 Author Share Posted August 12, 2018 What do I do after I recognize whether it's a L- or R- tray click ? That's what I want to know. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 12, 2018 Moderators Share Posted August 12, 2018 gbrao, I have used something like this in the past: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <TrayConstants.au3> Opt("TrayOnEventMode", 1) ; Use event trapping for tray menu Opt("TrayMenuMode", 3) ; Default tray menu items will not be shown. TrayCreateItem("Tray Item") TrayItemSetOnEvent(-1, "_TrayItem") TrayCreateItem("") TrayCreateItem("Tray Exit") TrayItemSetOnEvent(-1, "_Exit") TraySetState() ; Only left click will display tray menu TraySetClick(8) ; Set right click to display user GUI menu TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "_UserMenu") ; Create and hide user menu GUI $hUser_GUI = GUICreate("User Menu", 200, 200, -1, -1, $WS_POPUP) $cUser_Item = GUICtrlCreateLabel("User Item", 10, 10, 180, 20) $cUser_Close = GUICtrlCreateLabel("User Close", 10, 30, 180, 20) $cUser_Exit = GUICtrlCreateLabel("User Exit", 10, 50, 180, 20) GUISetState(@SW_HIDE) While 1 Switch GUIGetMsg() Case $cUser_Item ; Hide user menu GUISetState(@SW_HIDE) MsgBox($MB_SYSTEMMODAL, "User Item", "Clicked") Case $cUser_Close ; Hide user menu GUISetState(@SW_HIDE) Case $cUser_Exit _Exit() EndSwitch WEnd Func _UserMenu() ; Get mouse position Local $aMousePos = MouseGetPos() ; Move user menu WinMove($hUser_GUI, "", $aMousePos[0] - 200, $aMousePos[1] - 200) ; Show user menu GUISetState(@SW_SHOW) EndFunc Func _TrayItem() MsgBox(0, "Tray Item", "Clicked") EndFunc Func _Exit() Exit EndFunc Obviously the user menu GUI needs to be "prettified" but the idea is there. M23 gbrao and Xandy 2 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