Creates a menuitem control for the tray.
TrayCreateItem ( "text" [, menuID = -1 [, menuentry = -1 [, menuradioitem = 0]]] )
If the 'text' parameter is an empty string ( "" ) then a separator line is created.
By default, normal checked menuitems (not radio menuitems) will be automatically unchecked if you click it!
To turn off this behaviour use Opt("TrayMenuMode", 2).
Radio menuitems are automatically grouped together and these groups are separated by a separator line or a normal item which is not a radio item.
By default, a clicked radio menuitem will be checked automatically and all other radio items in the same group will be unchecked!
To turn off this behaviour use Opt("TrayMenuMode", 8).
TrayGetMsg, TrayItemDelete, TrayItemSetOnEvent, TrayItemSetState, TrayItemSetText
#NoTrayIcon
#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
#include <TrayConstants.au3>; Required for the $TRAY_CHECKED and $TRAY_ICONSTATE_SHOW constants.
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()
; Create a tray item with the radio item parameter selected.
TrayCreateItem ("Radio 1",- 1,- 1,$TRAY_ITEM_RADIO)
TrayItemSetState (-1,$TRAY_CHECKED)
TrayCreateItem ("Radio 2",- 1,- 1,$TRAY_ITEM_RADIO)
TrayCreateItem ("Radio 3",- 1,- 1,$TRAY_ITEM_RADIO)
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 $idExit; Exit the loop.
ExitLoop
EndSwitch
WEnd
EndFunc ;==>Example