Function Reference


TraySetState

Sets the state of the tray icon.

TraySetState ( [flag = 1] )

Parameters

flag [optional] A combination of the following:
    $TRAY_ICONSTATE_SHOW (1) = Shows the tray icon (default)
    $TRAY_ICONSTATE_HIDE (2) = Destroys/Hides the tray icon
    $TRAY_ICONSTATE_FLASH (4) = Flashes the tray icon
    $TRAY_ICONSTATE_STOPFLASH (8) = Stops tray icon flashing
    $TRAY_ICONSTATE_RESET (16) = Resets the icon to the defaults (no flashing, default tip text)

Constants are defined in TrayConstants.au3.

Return Value

None.

Remarks

This function overrides Opt("TrayIconHide") and #NoTrayIcon.
The normal and pause tray icon are NOT reset by this function!

Related

TrayItemSetState, TraySetIcon, TraySetPauseIcon

Example

#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <TrayConstants.au3> ; Required for the $TRAY_ICONSTATE_SHOW constant.

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.

Example()

Func Example()
        Local $idFlash = TrayCreateItem("Flash Icon")
        TrayCreateItem("") ; Create a separator line.

        Local $idAbout = TrayCreateItem("About")
        TrayCreateItem("") ; Create a separator line.

        Local $idExit = TrayCreateItem("Exit")

        TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.

        While 1
                Switch TrayGetMsg()
                        Case $idAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
                                MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _
                                                "Version: " & @AutoItVersion & @CRLF & _
                                                "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1)) ; Find the folder of a full path.

                        Case $idFlash
                                ; Start flashing the tray icon.
                                TraySetState($TRAY_ICONSTATE_FLASH)
                                Sleep(5000) ; Wait for 5 seconds.
                                ; Stop flashing the tray icon.
                                TraySetState($TRAY_ICONSTATE_STOPFLASH)

                        Case $idExit ; Exit the loop.
                                ExitLoop
                EndSwitch
        WEnd
EndFunc   ;==>Example