在系统托盘上面创建一个菜单控件.
TrayCreateMenu ( "子菜单/菜单文本" [, 菜单ID [, 菜单索引]] )
子菜单/菜单文本 | 子菜单/菜单文本. |
菜单ID | [可选参数] 如果定义,您创建的子菜单会创建到您引用的菜单里面,如果= -1 就创建到第一级菜单. |
菜单索引 | [可选参数] 允许定义要创建的菜单的(次序)编号.编号从0开始. |
成功: | 返回创建的新托盘菜单的控件ID (controlID). |
失败: | 返回 0. |
#NoTrayIcon
Opt("TrayMenuMode", 3) ; 默认菜单项目 (脚本暂停中/退出)(Script Paused/Exit) 将不会显示,并且所选项目不能被选中(checkbox不会打勾) . 请参考TrayMenuMode选项1和2(3=1+2).
Example()
Func Example()
Local $iSettings = TrayCreateMenu("设置")
Local $iDisplay = TrayCreateItem("显示", $iSettings)
Local $iPrinter = TrayCreateItem("打印", $iSettings)
TrayCreateItem("") ; Create a separator line.
Local $iAbout = TrayCreateItem("关于")
TrayCreateItem("") ; Create a separator line.
Local $iExit = TrayCreateItem("退出")
TraySetState(1) ; Show the tray menu.
While 1
Switch TrayGetMsg()
Case $iAbout ; Display a message box about the AutoIt version and installation path of the AutoIt executable.
MsgBox(4096, "", "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(4096, "", "A sub menu item was selected from the tray menu.")
Case $iExit ; Exit the loop.
ExitLoop
EndSwitch
WEnd
EndFunc ;==>Example