添加随系统启动提示非数组变量使用了下标?[已解决]
本帖最后由 虎虎虎 于 2012-2-26 11:19 编辑源码来自本站,地址分别是:
一个可以读取配置文件的托盘源码(原创)]
关于托盘跟随系统启动问题(图+源码) [已解决]
运行没有报错,设置随系统启动开机时报错。
错误截图:
修改后源码:#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=C:\Windows\system32\SHELL32.dll|-25
#AutoIt3Wrapper_Outfile=常用托盘程序.exe
#AutoIt3Wrapper_Res_Comment=常用托盘程序
#AutoIt3Wrapper_Res_Description=常用托盘程序1.0
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=常用托盘程序1.0
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
;---------------------------------------------------------程序源码------------------------------------------------
#include <File.au3>
#include <Constants.au3>
$iniFile = "TrayMenu.ini"
$varTrayMenuList = IniReadSection($iniFile, "TrayMenu")
$varTrayItemList = IniReadSection($iniFile, "TrayItem")
$tempFile = _TempFile()
Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode",3)
TraySetClick(16)
If @error Then
MsgBox(4096, "", "错误, 读取INI文件失败.")
Exit
Else
For $i = 1 To $varTrayMenuList
$menu = TrayCreateMenu($varTrayMenuList[$i])
For $j = 1 To $varTrayItemList
If ($varTrayItemList[$j] == $varTrayMenuList[$i]) Then
$temp = StringSplit($varTrayItemList[$j], ";")
$tid = TrayCreateItem($temp, $menu)
TrayItemSetOnEvent($tid, "RunApp")
IniWrite($tempFile, "TrayMenu", $tid, $temp)
EndIf
Next
Next
EndIf
$varMenuKeyList = IniReadSection($tempFile, "TrayMenu")
;===================================================================
Local $sRegPath = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
TrayCreateItem("")
$MenRun = TrayCreateMenu("随机启动")
$Yes = TrayCreateItem("跟随系统启动",$MenRun)
$No = TrayCreateItem("不随系统启动",$MenRun)
If RegRead($sRegPath, @ScriptName) <> '' Then
TrayItemSetState($Yes,$TRAY_CHECKED)
Else
TrayItemSetState($No,$TRAY_CHECKED)
EndIf
;===================================================================
TrayCreateItem("")
$exititem = TrayCreateItem("退出")
TrayItemSetOnEvent($Yes, "RunFun")
TrayItemSetOnEvent($No, "NoRunFun")
TrayItemSetOnEvent($exititem, "ExitFun")
TraySetState()
TraySetToolTip("常用托盘程序!")
While 1
Sleep(500)
WEnd
Exit
Func RunApp()
For $k = 1 To $varMenuKeyList
If ($varMenuKeyList[$k] == @TRAY_ID) Then
ShellExecute($varMenuKeyList[$k])
EndIf
Next
EndFunc ;==>RunApp
Func RunFun()
RegWrite($sRegPath, @ScriptName, 'REG_SZ', '"' & @ScriptFullPath & '" /AUTO')
TrayItemSetState($Yes,$TRAY_CHECKED)
TrayItemSetState($No, $TRAY_UNCHECKED)
EndFunc ;==>RunFun
Func NoRunFun()
RegDelete($sRegPath, @ScriptName)
TrayItemSetState($Yes, $TRAY_UNCHECKED)
TrayItemSetState($No,$TRAY_CHECKED)
EndFunc ;==>RunFun
Func ExitFun()
Exit
EndFunc ;==>ExitFun
配置文件代码:;---------------------------------------------------------配置文件TrayMenu.ini------------------------------------
1=常用网址
2=常用文件夹
1=百度一下;http://www.baidu.com
1=114啦;http://www.114la.com/kp.html
1=IT天空;http://sky123.org/
1=autoit中文网址;http://www.autoitx.com/index.php
2=文件夹测试;F:\文件夹\
;---------------------------------------------------------配置文件TrayMenu.ini------------------------------------ 本帖最后由 lixiaolong 于 2012-2-26 11:12 编辑
可能找不到"TrayMenu.ini"
应该把 $iniFile = "TrayMenu.ini" 改为
$iniFile = @ScriptDir & "\TrayMenu.ini" 就可以了. 谢谢小龙,问题解决了。 TrayMenu.ini 请指定路径。。。
页:
[1]