February 1, 2021

AutoHotkey: Custom Tray Icon Clicks

Normally AuoHotkey Tray Icon only enables a context menu that you can reach out via right-mouse click on the icon. I explain in this post how you can customize different click actions on the Script tray icon - for example add a left-mouse click action and another for right-mouse click.

NotifyTrayClick

I have found this solution in the AutoHotkey forum. This requires to copy this NotifyTrayClick function in your AHK script e.g. at the bottom.

(Link to Gist)

Then add the labels you need following this table/ values:

NotifyTrayClick_201: ; Left click (Button down) NotifyTrayClick_202: ; Left click (Button up) NotifyTrayClick_203: ; Left double click NotifyTrayClick_204: ; Right click (Button down) NotifyTrayClick_205: ; Right click (Button up) NotifyTrayClick_206: ; Right double click NotifyTrayClick_207: ; Middle click (Button down) NotifyTrayClick_208: ; Middle click (Button up) NotifyTrayClick_209: ; Middle double click

Example

In TeamsShortcuts I have moved the Tray menu as Left-Mouse Click action and assigned to Middle-click-> Toggle Mute and Right-click->Toggle Video.

The code looks like this:
NotifyTrayClick_208:   ; Middle click (Button up)
Teams_Mute()
Return 

NotifyTrayClick_202:   ; Left click (Button up)
Menu, Tray, Show
Return

NotifyTrayClick_205:   ; Right click (Button up)
Teams_Video()
Return 

See also

NotifyTrayClick() : Notifies when AHK tray icon is clicked | AutoHotkey Forum post


No comments:

Post a Comment