The basic difficulty - definition of a source of users select (an icon or the menu). The first variant: with definition of event " the right key of the mouse has been pressed, so the menu has been shown "
#Persistent Hotkey, RButton, RightClick Menu, Tray, Click, 1 Menu, Tray, NoStandard Menu, Tray, Add, Single Click, SingleClick Menu, Tray, Add, Double Click, DoubleClick Menu, Tray, Default, Double Click Menu, Tray, Add, Exit Return DoubleClick: If RClicked <> Yes { If Clicks = { SetTimer, SingleClick, 500 Clicks = 1 Return } } SetTimer, SingleClick, Off MsgBox, 0, Message, Double Click Detected! Clicks = RClicked = Return SingleClick: SetTimer, SingleClick, Off MsgBox, 0, Message, Single Click Detected! Clicks = RClicked = Return RightClick: RClicked = Yes GetKeyState, state, RButton, P If state = D { Send, {RButton down} KeyWait, RButton Send, {RButton up} } Else { Send, {RButton} } RClicked = Return Exit: ExitApp
The second variant: with definition of event " after the first click the mouse is not above a system tray, so the menu has been shown and the item of the menu was selected"
#Persistent Menu, Tray, Click, 1 Menu, Tray, NoStandard Menu, Tray, Add, Single Click, SingleClick Menu, Tray, Add, Double Click, DoubleClick Menu, Tray, Default, Double Click Menu, Tray, Add, Exit Return DoubleClick: MouseGetPos, , , WhichWindow, WhichControl WinGetClass, WhichClass, ahk_id %WhichWindow% If WhichClass = Shell_TrayWnd { IfInString, WhichControl, ToolbarWindow32 { If Clicks = { SetTimer, SingleClick, 500 Clicks = 1 Return } } } SetTimer, SingleClick, Off Sleep, 500 MsgBox, 0, Message, Double Click Detected! Clicks = Return SingleClick: SetTimer, SingleClick, Off MsgBox, 0, Message, Single Click Detected! Clicks = Return Exit: ExitApp
It is necessary only to exclude threefold- and multiply-clicks (sorry, but I donĀ“t know). Any ideas?