Tray

Tray icons controller

Summary
Tray icons controller
Add new icon in the system tray
Modify icon properties
Remove tray icon

Add

Tray_Add(hGui,  
fun,  
ico,  
txt = "")

Add new icon in the system tray

Parameters

hGuiHandle of the parent window (the one that monitors notification messages)
funNotification subroutine
icoIcon path or handle.  Icons allocated by module will be automatically destroyed when Remove function returns.  If the user passed icon handle, Remove will not destroy it.
txtOptional tooltip text

Globals

Tray_HWNDHandle of the tray icon
Tray_EVENTTray event

Events

Notification subroutine will be called on mouse events.  You can receive L,R and M events (left, right and middle button click) and “Move” event on mouse move.  Additionally, “u” or “d” can follow event name meaning “up” and “doubleclick”.

Returns

0 on failure, handle on success.  This handle is used with other Tray functions.

Modify

Tray_Modify(hGui,  
hTray,  
ico,  
txt = "")

Modify icon properties

Parameters

hGuiHandle of the parent window (the one that monitors notification messages)
hTrayHandle of the tray icon (returned by Add function)
icoIcon path or handle, set to “” to skip
txtNew ToolTip, set to “-” to remove tooltip completely.

Returns

TRUE on success, FALSE otherwise

Remove

Tray_Remove(hGui,
hTray)

Remove tray icon

Parameters

hGuiHandle of the parent window
hTrayHandle of the tray icon

Returns

TRUE on success, FALSE otherwise

Example

    Gui,  +LastFound
hGui := WinExist()

hTrayIcon := Tray_Add( hGui, "OnTrayIcon", "TrayIcon.ico", "My Tray Icon")
return

OnTrayIcon:
if (Tray_EVENT != "R") ;return if event is not right click
return

MsgBox Right Button clicked
return
Tray_Add(hGui,  
fun,  
ico,  
txt = "")
Add new icon in the system tray
Tray_Modify(hGui,  
hTray,  
ico,  
txt = "")
Modify icon properties
Tray_Remove(hGui,
hTray)
Remove tray icon