Creates a menuitem control for the tray.
TrayCreateItem ( text [, menuID [, menuentry [, menuradioitem]]] )
| text | The text of the control. |
| menuID | [optional] Allows you to create a submenu in the referenced menu. If equal -1 it will be added 'behind' the last created item (default setting). |
| menuentry | [optional] Allows you to define the entry number to be created. The entries are numbered starting at 0. If equal -1 it will be added 'behind' the last created entry (default setting). |
| menuradioitem | [optional] 0 (default) = create a normal menuitem, 1 = create a menuradioitem. |
| Success: | Returns the identifier (controlID) of the new tray menuitem. |
| Failure: | Returns 0. |
; ****************
; * First sample *
; ****************
#NoTrayIcon
Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown.
Local $prefsitem = TrayCreateItem("Preferences")
TrayCreateItem("")
Local $aboutitem = TrayCreateItem("About")
TrayCreateItem("")
Local $exititem = TrayCreateItem("Exit")
TraySetState()
While 1
Local $msg = TrayGetMsg()
Select
Case $msg = 0
ContinueLoop
Case $msg = $prefsitem
MsgBox(64, "Preferences:", "OS:" & @OSVersion)
Case $msg = $aboutitem
MsgBox(64, "About:", "AutoIt3-Tray-sample.")
Case $msg = $exititem
ExitLoop
EndSelect
WEnd
Exit
; *****************
; * Second sample *
; *****************
#include <Constants.au3>
#NoTrayIcon
Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown.
; Let's create 2 radio menuitem groups
Local $radio1 = TrayCreateItem("Radio1", -1, -1, 1)
TrayItemSetState(-1, $TRAY_CHECKED)
TrayCreateItem("Radio2", -1, -1, 1)
TrayCreateItem("Radio3", -1, -1, 1)
TrayCreateItem("") ; Radio menuitem groups can be separated by a separator line or another norma menuitem
TrayCreateItem("Radio4", -1, -1, 1)
TrayCreateItem("Radio5", -1, -1, 1)
TrayItemSetState(-1, $TRAY_CHECKED)
TrayCreateItem("Radio6", -1, -1, 1)
TrayCreateItem("")
$aboutitem = TrayCreateItem("About")
TrayCreateItem("")
$exititem = TrayCreateItem("Exit")
TraySetState()
While 1
$msg = TrayGetMsg()
Select
Case $msg = 0
ContinueLoop
Case $msg = $aboutitem
MsgBox(64, "About:", "AutoIt3-Tray-sample with radio menuitem groups.")
Case $msg = $exititem
ExitLoop
EndSelect
WEnd
Exit