TrayMenu.au3;读取INI信息,生成对应的托盘菜单项,配置文件有两种方式,哪个方便用哪个,紧急求助,谢谢
#include <File.au3>
#include <ModernMenuRaw.au3>
$DefaultMenuSet = "<TrayMenu.ini>丢失"
;Menu0
$Menu0name = IniRead("TrayMenu.ini","SetMenu","Menu0name",$DefaultMenuSet)
$Menu0path = IniRead("TrayMenu.ini","SetMenu","Menu0path",$DefaultMenuSet)
$Menu1name = IniRead("TrayMenu.ini","SetMenu","Menu1name",$DefaultMenuSet)
$Menu1path = IniRead("TrayMenu.ini","SetMenu","Menu1path",$DefaultMenuSet)
;读取INI里面的$Menu(n)name,$Menu(n)path ,INI里面有多少就读取多少
#NoTrayIcon
$nTrayIcon1 = _TrayIconCreate("托盘菜单示例", "icon.ico");
_TrayIconSetClick(-1, 16)
_TrayIconSetState()
$bUseAdvTrayMenu = FALSE
$nTrayMenu1 = _TrayCreateContextMenu()
$nSideItem3 = _CreateSideMenu($nTrayMenu1)
_SetSideMenuText($nSideItem3, "我的菜单")
_SetSideMenuColor($nSideItem3, 0xFFFFFF)
_SetSideMenuBkColor($nSideItem3, 0x666666)
_SetSideMenuBkGradColor($nSideItem3, 0xCCCCCC)
$menu0name = _TrayCreateItem($Menu0name)
_TrayItemSetIcon($Menu0name, $Menu0path, 0)
$menu1name = _TrayCreateItem($Menu1name)
_TrayItemSetIcon($Menu1name, $Menu1path, 0)
;根据上面读取INI里面的Menu(n)name,Menu(n)path生成$Menu(n)name, INI里面读取多少就生成多少
_TrayCreateItem("")
$SelfRun = _TrayCreateItem("Auto Run")
_TrayItemSetIcon($SelfRun, "shell32.dll", -25)
_TrayCreateItem("")
$TrayExit = _TrayCreateItem("Exit")
_TrayItemSetIcon(-1, "shell32.dll", -28)
_TrayIconSetState();
While 1
Sleep(10)
$Msg = GUIGetMsg()
Select
Case $Msg = $TrayExit
ExitLoop
Case $Msg = $menu0name
ShellExecute($Menu0path, "", "", "open")
Case $Msg = $menu1name
ShellExecute($Menu1path, "", "", "open")
;根据上面读取INI里面的Menu(n)name,Menu(n)path生成$Menu(n)name, INI里面读取多少就生成多少,运行生成的那些$menu(n)name
Case $msg = $SelfRun
Msgbox(64,"selfrun","selfrun")
;勾上就开机自动运行,不勾就不自动运行,勾勾在托盘菜单对于的Auto Run字样后面显示.
EndSelect
WEnd
_TrayIconDelete($nTrayIcon1)
TrayMenu.ini[SetMenu]
Menu0name = 菜单0
Menu0path = msgbox.exe
Menu1name = 菜单1
Menu1path = msgbox.exe
Menu2name = 菜单2
Menu2path = msgbox.exe
TrayMenu0.ini[SetMenu]
[SetMenu1]
Menuname = 菜单0
Menupath = msgbox.exe
[SetMenu2]
Menuname = 菜单1
Menupath = msgbox.exe
[SetMenu3]
Menuname = 菜单2
Menupath = msgbox.exe
求助附件: |