#TrayIcon [Keysharp]

Selects and embeds the tray icon with which the script starts, or restores the script's default icon.

#TrayIcon
#TrayIcon FileName , IconNumber

Parameters

FileName

The path to an icon file or an icon-bearing module. It must be relative to the main script's directory, even when #TrayIcon appears in an #Included file. A rooted path is a compile-time error.

If omitted, the tray is made visible with the script's default icon: the #App Icon, if present, or Keysharp's built-in icon.

IconNumber

If omitted, the first icon group is selected. A positive integer selects a 1-based icon group; a negative integer selects the icon whose resource ID is the absolute value. A nonnumeric quoted string selects a named icon resource from a managed .NET assembly.

Numeric icon selection from a native module is supported only on Windows.

Remarks

The selected icon is embedded in the script assembly, including for source and in-memory execution, so the original file is not read when the script runs. After TraySetIcon selects another icon, TraySetIcon("*") restores this one.

#TrayIcon and #NoTrayIcon are applied in source order. Any #TrayIcon, with or without a file, cancels an earlier #NoTrayIcon and makes the tray visible. A later #NoTrayIcon hides an icon selected earlier.

Like other directives, #TrayIcon cannot be executed conditionally.

#NoTrayIcon, #App Icon, TraySetIcon, A_IconHidden, Tray Icon

Examples

Selects the second icon group from a file relative to the main script.

#TrayIcon "assets/status.dll", 2

Restores the default icon and makes it visible after an earlier #NoTrayIcon.

#NoTrayIcon
#TrayIcon