函数参考


TrayGetMsg

得到一个系统托盘图标项目产生的事件.

TrayGetMsg ( )

参数

None.

返回值

返回一个事件.
"事件"是由控件发送的控件标识消息返回的, 或者它是一个特殊事件 (就像鼠标点击 托盘图标). 或者没有发生事件,事件值为 0.


事件 ID
0 没有事件发生
Control ID 发送消息的控件标识
$TRAY_EVENT_PRIMARYDOWN 鼠标主要按键被点击(默认左键)
$TRAY_EVENT_PRIMARYUP 鼠标主要按键被释放(默认左键)
$TRAY_EVENT_SECONDARYDOWN 鼠标次要按键被点击(默认右键)
$TRAY_EVENT_SECONDARYUP 鼠标次要按键被释放(默认右键)
$TRAY_EVENT_PRIMARYDOUBLE 鼠标主要按键双击(默认左键)
$TRAY_EVENT_SECONDARYDOUBLE 鼠标次要按键双击(默认右键)

注意/说明

这个函数会自动空闲CPU,注意使用正确的循环模式以降低CPU的占用.

上面这些常量定义于 #include <Constants.au3>

相关

TrayCreateItem, TrayCreateMenu, TrayItemSetOnEvent

示例/演示


#NoTrayIcon

Opt("TrayMenuMode", 3) ; 默认菜单项目 (脚本暂停中/退出)(Script Paused/Exit) 将不会显示,并且所选项目不能被选中(checkbox不会打勾) . 请参考TrayMenuMode选项1和2(3=1+2).

Example()

Func Example()
    Local $iAbout = TrayCreateItem("关于")
    TrayCreateItem("") ; 创建一个分割条.

    Local $iExit = TrayCreateItem("退出")

    TraySetState(1) ; 显示托盘菜单.

    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 $iExit ; Exit the loop.
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>Example