Tray icon controller
Using this module you can totally control Windows notification area. Your script can create any number of tray icons and receive notifications about user actions on them. Also, you can get and modify 3thd party tray icons information.
Tray | Tray icon controller |
Add | Add icon in the system tray. |
Click | Click the tray icon. |
Count | Get the number of icons in the notificaiton area. |
Define | Get information about system tray icons. |
Disable | Disable the notification area. |
Focus | Focus notification icon or window. |
GetRect | Get tray icon rect. |
GetTooltip | Get tooltip of the tray icon. |
Modify | Modify icon properties. |
Move | Move the tray icons. |
Remove | Removes the tray icon. |
Refresh | Refresh tray icons. |
Example | |
About |
Tray_Add( hGui, Handler, Icon, Tooltip = "" )
Add icon in the system tray.
hGui | Handle of the parent window. |
Handler | Notification handler. |
Icon | Icon path or handle. Icons allocated by module will be automatically destroyed when Remove function returns. If you pass icon handle, Remove will not destroy it. If path is an icon resource, you can use “path:idx” notation to get the handle of the desired icon by its resource index (0 based). |
Tooltip | Tooltip text. |
Handler(Hwnd, Event)
Hwnd | Handle of the tray icon. |
Event | L (Left click), R(Right click), M (Middle click), P (Position - mouse move). Additionally, “u” or “d” can follow event name meaning “up” and “doubleclick”. For example, you will be notified on “Lu” when user releases the left mouse button. |
0 on failure, handle on success.
Tray_Define( Filter = "", pQ = "", ByRef o1 = "~`a ", ByRef o2 = "", ByRef o3 = "", ByRef o4 = "", ByRef o5 = "", ByRef o6 = "", ByRef o7 = "" )
Get information about system tray icons.
Filter | Contains process name, ahk_pid, ahk_id or 1-based position for which to return information. If you specify position as Filter, you can use output variables to store information. |
pQ | Query parameter, by default “ihw”. |
o1..o4 | Reference to output variables. |
h | Handle. |
i | PosItion (1 based). |
w | Parent Window handle. |
p | Process Pid. |
n | Process Name. |
m | Message id. |
o | IcOn handle. |
String containing icon information per line.
Tray_Focus( hGui = "", hTray = "" )
Focus notification icon or window.
hGui | Handle of the parent window. |
hTray | Tray icon handle. This icon will be focused. As a consequence, you can use SPACEBAR or ENTER instead left click and windows popup keyboard button as rclick. Arrows can be used to select other icons. However, there is no visual representation of selection apart from the tooltip that is shown after few moments. |
If both parameters are missing, function will focus Notification area.
Tray_GetRect( Position, ByRef x = "", ByRef y = "", ByRef w = "", ByRef h = "" )
Get tray icon rect.
Position | Position of the tray icon. Use negative position to retreive client coordinates. |
x-h | Refrence to outuptu variables, optional. |
String containing all outuput variables.
This function can be used to determine if tray icon is hidden. Such tray icons will have string “0 0 0 0” returned.
Add icon in the system tray.
Tray_Add( hGui, Handler, Icon, Tooltip = "" )
Click the tray icon.
Tray_Click( Position, Button = "L" )
Get the number of icons in the notificaiton area.
Tray_Count()
Get information about system tray icons.
Tray_Define( Filter = "", pQ = "", ByRef o1 = "~`a ", ByRef o2 = "", ByRef o3 = "", ByRef o4 = "", ByRef o5 = "", ByRef o6 = "", ByRef o7 = "" )
Disable the notification area.
Tray_Disable( bDisable = true )
Focus notification icon or window.
Tray_Focus( hGui = "", hTray = "" )
Get tray icon rect.
Tray_GetRect( Position, ByRef x = "", ByRef y = "", ByRef w = "", ByRef h = "" )
Get tooltip of the tray icon.
Tray_GetTooltip( Position )
Modify icon properties.
Tray_Modify( hGui, hTray, Icon, Tooltip = "~`a " )
Move the tray icons.
Tray_Move( Pos, NewPos = "" )
Removes the tray icon.
Tray_Remove( hGui, hTray = "" )
Refresh tray icons.
Tray_Refresh()