TrayTip

Shows a balloon message window or, on Windows 10 and later, a toast notification near the tray icon.

TrayTip Text, Title, Options

パラメータ

Text

型:文字列

If blank or omitted, the text will be entirely omitted from the traytip, making it vertically shorter. Otherwise, specify the message to display. 最初の265文字だけが表示されます。

キャリッジリターン(`r)またはラインフィード(`n)を使って複数行のテキストを作成することができる。事例:Line1`nLine2.

Textが長い場合、継続セクションによっていくつかの短い行に分割することができ、読みやすさと保守性を向上させることができるかもしれません。

タイトル

型:文字列

If blank or omitted, the title line will be entirely omitted from the traytip, making it vertically shorter. Otherwise, specify the title of the traytip. 最初の73文字のみが表示されます。

Options

型:文字列または整数

空白または省略された場合、デフォルトは 0 です。Otherwise, specify 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. また、1つ以上の数値オプションを文字列に含めることができます。

機能 Dec Hex String
No icon 0 0x0 N/A
Info icon 1 0x1 Iconi
Warning icon 2 0x2 Icon!
Error icon 3 0x3 Iconx
Tray icon 4 0x4 N/A
通知音を鳴らさない。 16 0x10 Mute
アイコンの大きいバージョンを使用してください。 32 0x20 N/A

The icon is also not shown by the traytip if it lacks a title (this does not apply to the toast notifications on Windows 10 and later).

On Windows 10 and later, 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.

Hiding the Traytip

To hide the traytip, omit all parameters (or at least the Text and Title parameters). 事例:

TrayTip

To hide the traytip on Windows 10, temporarily remove the tray icon (which not always work, according to at least one report). 事例:

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
    }
}

備考

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

TrayTip

Windows 10 and later replace all balloon windows with toast notifications by default (this can be overridden via group policy). TrayTipを複数回呼び出すと、通常、各通知が最後の通知を置き換えるのではなく、複数の通知が「キュー」に入れられます。

TrayTipは、スクリプトにトレイアイコンがない場合(#NoTrayIconまたはA_IconHidden:=trueを使用)には効果がありません。また、以下のREG_DWORD値が存在し、0に設定されている場合、TrayTipは効果を発揮しません:

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

関連して、ユーザーがスクリプトのトレイアイコンにマウスを置くと、ツールチップが表示される。このツールチップの内容は、以下の方法で変更できる:A_IconTip := "My New Text".

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

通知音を再生せずに、トレイアイコンの近くに20秒間、複数行のバルーンメッセージまたはトースト通知を表示します。また、タイトルがあり、情報アイコンが含まれている。

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

スリープ(現在のスレッドを停止させる)を使うことなく、表示時間をより正確にコントロールできる。

TrayTip "This will be displayed for 5 seconds.", "Timed traytip"
SetTimer () => TrayTip(), -5000

The following does the same, but allows you to replace the HideTrayTip function definition with the one defined above for Windows 10.

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 and later 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"
}