TraySetIcon

Changes the script's tray icon (which is also used by GUI and dialog windows).

TraySetIcon(FileName, IconNumber, Freeze)

Parameters

FileName

Type: String

The path of an icon or image file. For a list of supported formats, see the Picture control.

Specify an asterisk (*) to restore the script to its default icon.

IconNumber

Type: Integer

To use an icon group other than the first one in the file, specify its number for IconNumber (if omitted, it defaults to 1). For example, 2 would load the default icon from the second icon group. If IconNumber is negative, its absolute value is assumed to be the resource ID of an icon within an executable file.

Freeze

Type: Integer (boolean)

Specify 1 (true) to freeze the icon, or 0 (false) to unfreeze it (or omit it to keep the frozen/unfrozen state unchanged). When the icon has been frozen, Pause and Suspend will not change it. Note: To freeze or unfreeze the current icon, use 1 (true) or 0 (false) as in the following example: TraySetIcon(,, 1).

Remarks

Changing the tray icon also changes the icon displayed by InputBox and subsequently-created GUI windows. Compiled scripts are also affected even if a custom icon was specified at the time of compiling. Note: Changing the icon will not unhide the tray icon if it was previously hidden by means such as #NoTrayIcon; to do that, use A_IconHidden := false.

Slight distortion may occur when loading tray icons from file types other than .ICO. This is especially true for 16x16 icons. To prevent this, store the desired tray icon inside a .ICO file.

There are some icons built into the operating system's DLLs and CPLs that might be useful. For example: TraySetIcon "Shell32.dll", 174.

A bitmap or icon handle can be used instead of a filename. For example, TraySetIcon "HBITMAP:" handle.

The built-in variables A_IconNumber and A_IconFile contain the number and name (with full path) of the current icon (both are blank if the icon is the default).

The tray icon's tooltip can be changed by assigning a value to A_IconTip.

Related

#NoTrayIcon, TrayTip, Menu object