TrayTip

Creates a balloon message window near the tray icon. On Windows 10, a toast notification may be shown instead.

TrayTip Text, Title, Options

Parameters

Text

Type: String

The message to display. Only the first 265 characters will be displayed.

Carriage return (`r) or linefeed (`n) may be used to create multiple lines of text. For example: Line1`nLine2.

If Text is long, it can be broken up into several shorter lines by means of a continuation section, which might improve readability and maintainability.

It is possible to show a window with only a title by leaving Text blank.

Title

Type: String

The title of the window. Only the first 73 characters will be displayed.

If Title is blank, the title line will be entirely omitted from the window, making it vertically shorter.

Options

Type: String or Integer

Either an integer value (a combination by addition or bitwise-OR) or a string of zero or more case-insensitive options separated by at least one space or tab. One or more numeric options may also be included in the string.

Function Dec Hex String
Info icon 1 0x1 Iconi
Warning icon 2 0x2 Icon!
Error icon 3 0x3 Iconx
Tray icon 4 0x4 N/A
Do not play the notification sound. 16 0x10 Mute
Use the large version of the icon. 32 0x20 N/A

If omitted, it defaults to 0, which is no icon. The icon is also not shown by the balloon window if it lacks a Title (this does not apply to Windows 10 toast notifications).

On Windows 10, the small tray icon is generally displayed even if the "tray icon" option (4) is omitted, and specifying this option may cause the program's name to be shown in the notification.

To Hide the Window

To hide a TrayTip balloon window, omit both Text and Title. For example:

TrayTip

To hide a Windows 10 toast notification, temporarily remove the tray icon. For example:

TrayTip "#1", "This is TrayTip #1"
Sleep 3000   ; Let it display for 3 seconds.
HideTrayTip
TrayTip "#2", "This is the second notification."
Sleep 3000

; Copy this function into your script to use it.
HideTrayTip() {
    TrayTip  ; Attempt to hide it the normal way.
    if SubStr(A_OSVersion,1,3) = "10." {
        A_IconHidden := true
        Sleep 200  ; It may be necessary to adjust this sleep.
        A_IconHidden := false
    }
}

This may not always work, according to at least one report.

Remarks

On Windows 10, a TrayTip window usually looks like this:

TrayTip

Windows 10 replaces all balloon windows with toast notifications by default (this can be overridden via group policy). Calling TrayTip multiple times will usually cause multiple notifications to be placed in a "queue" instead of each notification replacing the last.

TrayTip has no effect if the script lacks a tray icon (via #NoTrayIcon or A_IconHidden := true). TrayTip also has no effect if the following REG_DWORD value exists and has been set to 0:

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced >> EnableBalloonTips

On a related note, there is a tooltip displayed whenever the user hovers the mouse over the script's tray icon. The contents of this tooltip can be changed via: A_IconTip := "My New Text".

ToolTip, SetTimer, Menu object, MsgBox, InputBox, FileSelect, DirSelect

Examples

Shows a multiline balloon message or toast notification for 20 seconds near the tray icon without playing the notification sound. It also has a title and contains an info icon.

TrayTip "Multiline`nText", "My Title", "Iconi Mute"

Provides a more precise control over the display time without having to use Sleep (which would stop the current thread). For Windows 10, replace the HideTrayTip function definition with the one defined above.

TrayTip "This will be displayed for 5 seconds.", "Timed TrayTip"
SetTimer HideTrayTip, -5000

HideTrayTip() {
    TrayTip
}

Permanently displays a TrayTip by refreshing it periodically via timer. Note that this probably won't work well on Windows 10 for reasons described above.

SetTimer RefreshTrayTip, 1000
RefreshTrayTip  ; Call it once to get it started right away.

RefreshTrayTip()
{
    TrayTip "This is a more permanent TrayTip.", "Refreshed TrayTip", "Mute"
}