TrayCreateItem 循环菜单示例
写代码用到这个,论坛里搜索没找到相关信息估计是太简单没人发
放一下做示例好了
#include <TrayConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
Opt("TrayMenuMode", 3)
Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode.
Local $MenuItem
;生成菜单
For $i = 0 To 9
$MenuItem[$i] = TrayCreateItem("菜单 " & $i)
TrayItemSetOnEvent(-1, "TrayEvent")
Next
TrayCreateItem("")
Local $TrayAbout = TrayCreateItem("关于(&A)")
TrayItemSetOnEvent(-1, "_About") ;设置该菜单点击时需要调用的函数名称
TrayCreateItem("")
Local $TrayClose = TrayCreateItem("退出(&X)")
TrayItemSetOnEvent(-1, "_Close")
TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "TrayEvent") ;设置鼠标点击方式激活函数过程
TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "_About")
TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "_Close")
While 1
Sleep(100)
WEnd
Func TrayEvent()
MsgBox(0,@TRAY_ID,TrayItemGetText(@TRAY_ID)) ;请在 @TRAY_ID 处按F1
EndFunc ;==>About
Func _About()
MsgBox($MB_SYSTEMMODAL, "", "AutoIt 托盘菜单示例." & @CRLF & @CRLF & _
"AutoIt 版本: " & @AutoItVersion & @CRLF & _
"安装路径: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1)) ; 查找完整路径的文件夹.
EndFunc
Func _Close()
Exit
EndFunc
什么码。。。 看看{:face (130):} 进来看看大神的作品 学习学习。。。 m 循环菜单示例 回复看看。 既然是基础,这样可能更易懂。
#include <TrayConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
Opt("TrayMenuMode", 3)
Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode.
Local $MenuItem
;生成菜单
For $i = 0 To 9
$MenuItem[$i] = TrayCreateItem("菜单 " & $i)
TrayItemSetOnEvent(-1, "TrayEvent")
Next
TrayCreateItem("")
Local $TrayAbout = TrayCreateItem("关于(&A)")
TrayItemSetOnEvent(-1, "_About") ;设置该菜单点击时需要调用的函数名称
TrayCreateItem("")
Local $TrayClose = TrayCreateItem("退出(&X)")
TrayItemSetOnEvent(-1, "_Close")
TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "TrayEvent") ;设置鼠标点击方式激活函数过程
TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "_About")
TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "_Close")
While 1
Sleep(100)
WEnd
Func TrayEvent()
;MsgBox(0, @TRAY_ID, TrayItemGetText(@TRAY_ID))
Switch @TRAY_ID
Case $MenuItem
MsgBox(0, @TRAY_ID, TrayItemGetText(@TRAY_ID))
Case $MenuItem
MsgBox(0, @TRAY_ID, TrayItemGetText(@TRAY_ID))
Case $MenuItem
MsgBox(0, @TRAY_ID, TrayItemGetText(@TRAY_ID))
Case $MenuItem
MsgBox(0, @TRAY_ID, TrayItemGetText(@TRAY_ID))
Case $MenuItem
MsgBox(0, @TRAY_ID, TrayItemGetText(@TRAY_ID))
Case $MenuItem
MsgBox(0, @TRAY_ID, TrayItemGetText(@TRAY_ID))
Case $MenuItem
MsgBox(0, @TRAY_ID, TrayItemGetText(@TRAY_ID))
Case $MenuItem
MsgBox(0, @TRAY_ID, TrayItemGetText(@TRAY_ID))
Case $MenuItem
MsgBox(0, @TRAY_ID, TrayItemGetText(@TRAY_ID))
Case $MenuItem
MsgBox(0, @TRAY_ID, TrayItemGetText(@TRAY_ID))
EndSwitch
EndFunc ;==>TrayEvent
Func _About()
MsgBox($MB_SYSTEMMODAL, "", "AutoIt 托盘菜单示例." & @CRLF & @CRLF & _
"AutoIt 版本: " & @AutoItVersion & @CRLF & _
"安装路径: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1)) ; 查找完整路径的文件夹.
EndFunc ;==>_About
Func _Close()
Exit
EndFunc ;==>_Close
看看了,说不定还能用上 {:face (368):}
页:
[1]