Skip to content

Instantly share code, notes, and snippets.

@tdalon
Created February 1, 2021 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdalon/38526a2354864510a4d1de39a8b1757c to your computer and use it in GitHub Desktop.
Save tdalon/38526a2354864510a4d1de39a8b1757c to your computer and use it in GitHub Desktop.
NotifyTrayClick AutoHotkey function to customize tray icon click actions
NotifyTrayClick(P*) { ; v0.41 by SKAN on D39E/D39N @ tiny.cc/notifytrayclick
Static Msg, Fun:="NotifyTrayClick", NM:=OnMessage(0x404,Func(Fun),-1), Chk,T:=-250,Clk:=1
If ( (NM := Format(Fun . "_{:03X}", Msg := P[2])) && P.Count()<4 )
Return ( T := Max(-5000, 0-(P[1] ? Abs(P[1]) : 250)) )
Critical
If ( ( Msg<0x201 || Msg>0x209 ) || ( IsFunc(NM) || Islabel(NM) )=0 )
Return
Chk := (Fun . "_" . (Msg<=0x203 ? "203" : Msg<=0x206 ? "206" : Msg<=0x209 ? "209" : ""))
SetTimer, %NM%, % (Msg==0x203 || Msg==0x206 || Msg==0x209)
? (-1, Clk:=2) : ( Clk=2 ? ("Off", Clk:=1) : ( IsFunc(Chk) || IsLabel(Chk) ? T : -1) )
Return True
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment