TrayCreateMenu
创建托盘菜单控件.
TrayCreateMenu ( "sub/menutext" [, menuID = -1 [, menuentry = -1]] )
参数
sub/menutext
|
子菜单/菜单的文本.
|
menuID
|
[可选] 如果定义, 允许您在引用菜单中创建一个子菜单. 默认值 -1(第一个一级菜单).
|
menuentry
|
[可选] 定义创建菜单的条目编号. 条目编号从 0 开始. 默认值为 -1(在底部).
|
返回值
成功:
|
返回托盘菜单的控件ID.
|
失败:
|
返回 0.
|
相关
TrayGetMsg, TrayItemDelete, TrayItemSetState, TrayItemSetText
函数示例
#NoTrayIcon
#include <MsgBoxConstants.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 $iSettings = TrayCreateMenu("Settings") ; Create a tray menu sub menu with two sub items.
Local $iDisplay = TrayCreateItem("Display", $iSettings)
Local $iPrinter = TrayCreateItem("Printer", $iSettings)
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, "\", 0, -1) - 1)) ; Find the folder of a full path.
Case $iDisplay, $iPrinter
MsgBox($MB_SYSTEMMODAL, "", "A sub menu item was selected from the tray menu.")
Case $idExit ; Exit the loop.
ExitLoop
EndSwitch
WEnd
EndFunc ;==>Example
----------------------------------------
|