TrayGetMsg
获取托盘事件.
TrayGetMsg ( )
返回值
返回托盘事件.
"事件"返回发送消息的控件 ID, 或者特别事件(如鼠标点击托盘图标). 如没有发生事件, 则事件值为 0.
事件 ID
$TRAY_EVENT_NONE (0):
|
无事件
|
Control ID:
|
发送消息的控件标识符
|
$TRAY_EVENT_PRIMARYDOWN:
|
鼠标左键按下
|
$TRAY_EVENT_PRIMARYUP:
|
鼠标左键释放
|
$TRAY_EVENT_SECONDARYDOWN:
|
鼠标右键按下
|
$TRAY_EVENT_SECONDARYUP:
|
鼠标右键释放
|
$TRAY_EVENT_PRIMARYDOUBLE:
|
鼠标左键双击
|
$TRAY_EVENT_SECONDARYDOUBLE:
|
鼠标右键双击
|
常量定义在 TrayConstants.au3
备注
函数自动空闲 CPU, 因此可以安全地用在紧凑循环中, 不会占用所有的 CPU
相关
TrayCreateItem, TrayCreateMenu, TrayItemSetOnEvent
函数示例
#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 $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 $idExit ; Exit the loop.
ExitLoop
EndSwitch
WEnd
EndFunc ;==>Example
----------------------------------------
|