运行点点通”是一个方便用户管理开机自动运行程序的实用工具,可以安全而轻松地实现对注册表启动信息的添加、删除等管理,你需要做的只是按照提示操作,所有“危险”的任务均由程序智能分析和完成,可以说几乎能够把出错的风险降至为零。
编写软件的目的就是为了简化人们原本需要耗费大量精力的复杂性操作,软件的易用性即功能的“傻瓜化”已经成为越来越多的程序开发人员心中的共识。笔者也是基于这一原则,本着服务大众的态度,用并不精深的编程技巧实现对注册表一个局部功能的优化管理操作,以此作为方便更多希望深入了解系统而又不敢轻易尝试的朋友的一个小小的铺垫。
以下为程序运行时的截图:
图1.程序主界面
图2.系统托盘提示
图3.系统托盘右键菜单
图4.程序主菜单——基本功能
图5.程序主菜单——附加软件
图6.程序主菜单——查看系统信息
图7.程序主菜单——关于
图8.添加开机运行程序——后台文件路径校对
图9.添加开机运行程序——文件路径校对提示
图10.添加开机运行程序——文件路径校对合格
图10.添加开机运行程序——长文件路径自动处理(添加参数后的效果见图)
图11.添加开机运行程序——添加可选参数
图12.添加开机运行程序——添加完毕
图13.删减开机运行程序——启动信息管理器
图14.删减开机运行程序——勾选需要删除的开机运行程序
图15.删减开机运行程序——删除后自动刷新界面
图16.简易音乐播放器——主界面(未添加曲目)
图17.简易音乐播放器——支持的文件类型
图18.简易音乐播放器——添加曲目后
以下是全部源代码:
主程序
#include <GuiConstants.au3>
#include <file.au3>
#include <Constants.au3>
Opt("TrayMenuMode", 1)
TrayTip("欢迎使用", "开机运行点点通", 0)
Sleep(500)
Opt("TrayIconHide", 1)
Opt("TrayIconHide", 0)
TraySetTooltip("开机运行点点通")
Dim $back=0, $first=51
Global $num, $name[500], $val[100], $monitor=0
Dim $time=0, $1radio1="OK", $var="", $varislong=0
FileInstall("start.exe", @TempDir & "/start.exe")
FileInstall("pic.jpg", @TempDir & "/pic.jpg")
GuiCreate("开机运行点点通", 392, 316,(@DesktopWidth-392)/2,(@DesktopHeight-316)/2)
$toolsmenu = GUICtrlCreateMenu("基本功能(&T)")
$extramenu = GUICtrlCreateMenu("附加软件(&E)")
$sysinfomenu = GUICtrlCreateMenu("系统信息(&S)")
$aboutmenu = GUICtrlCreateMenu("关于(&A)")
$toolsitem1 = GUICtrlCreateMenuitem("添加开机运行程序", $toolsmenu)
$toolsitem2 = GUICtrlCreateMenuitem("删减开机运行程序", $toolsmenu)
$extraitem = GUICtrlCreateMenuitem("简易音乐播放器", $extramenu)
$sysinfoitem = GUICtrlCreateMenuitem("查看系统信息", $sysinfomenu)
$aboutitem = GUICtrlCreateMenuitem("关于本软件", $aboutmenu)
$pic_1=GUICtrlCreatePic(@TempDir & "/pic.jpg", 0, 0, 395, 220)
$Label_2 = GuiCtrlCreateLabel("<<<< 就绪...", 30, 225, 170, 20)
$Progress_3 = GuiCtrlCreateProgress(25, 242, 340, 10)
$Button_4 = GuiCtrlCreateButton("添加开机运行程序", 100, 260, 110, 30)
$Button_5 = GuiCtrlCreateButton("删减开机运行程序", 240, 260, 110, 30)
$Group_6 = GUICtrlCreateGroup("设置", 25, 10, 340, 240)
$Button_7 = GUICtrlCreateButton("浏 览", 295, 48, 50)
$label_8 = GUICtrlCreateLabel("需要开机自动运行的程序:", 45, 30, 185, 20)
$label_9 = GUICtrlCreateLabel("你还没有选择程序,所以无法设置其运行方式!", 45, 135, 260, 50)
$Group_10 = GUICtrlCreateGroup("运行方式选择", 45, 155, 160, 80)
$radio_11 = GUICtrlCreateRadio("开机自动运行", 55, 180, 120, 20)
GUICtrlSetState($radio_11, $GUI_CHECKED)
$radio_12 = GUICtrlCreateRadio("开机自动运行一次", 55, 205, 120, 20)
$Button_13 = GUICtrlCreateButton("确定(&O)", 250, 180)
$Button_14 = GUICtrlCreateButton("返回", 300, 260, 60, 30)
$input_15 = GUICtrlCreateInput("", 45, 50, 245, 20)
$Button_16 = GUICtrlCreateButton("编辑参数", 286, 73, 60, 24)
$label_17 = GUICtrlCreateLabel(" 如果需要添加特定的参数,请点击 ==>" & @CR & "当然,你也可以在上面的输入栏中直接追加。" & @CR & "此外对长路径名属后台处理,请勿人工干预,"& @CR & "即:遇到长路径名请不要在其两端加双引号!", 45, 80, 240, 50)
$start=TrayCreateItem("启动信息管理器(&S)")
TrayCreateItem("")
$Exit=TrayCreateItem("退出(&X)")
GUICtrlSetState($Button_13, $GUI_FOCUS)
;------------------- Hide Items -------------------
GuiCtrlSetState($Group_6, $GUI_HIDE)
GuiCtrlSetState($Button_7, $GUI_HIDE)
GuiCtrlSetState($label_8, $GUI_HIDE)
GuiCtrlSetState($label_9, $GUI_HIDE)
GuiCtrlSetState($group_10, $GUI_HIDE)
GuiCtrlSetState($radio_11, $GUI_HIDE)
GuiCtrlSetState($radio_12, $GUI_HIDE)
GuiCtrlSetState($Button_13, $GUI_HIDE)
GuiCtrlSetState($Button_14, $GUI_HIDE)
GuiCtrlSetState($input_15, $GUI_HIDE)
GuiCtrlSetState($Button_16, $GUI_HIDE)
GuiCtrlSetState($label_17, $GUI_HIDE)
;--------------------------------------------------
GuiSetState(@SW_SHOW)
While 1
$msg = GuiGetMsg()
$msg2 = TrayGetMsg()
Select
Case $msg=$GUI_EVENT_CLOSE Or $msg2=$Exit
ProcessClose("start.exe")
ProcessClose("ezMusicPlayer.exe")
FileDelete(@TempDir & "/start.exe")
FileDelete(@TempDir & "/ezMusicPlayer.exe")
FileDelete(@TempDir & "/pic.jpg")
ExitLoop
Case $msg=$button_5 Or $msg=$toolsitem2 Or $msg2=$start
call("search")
call("ini")
run(@TempDir & "/start.exe")
Case $msg=$Button_4 Or $msg=$toolsitem1
;------------------- Hide Items -------------------
GuiCtrlSetState($Pic_1, $GUI_HIDE)
GuiCtrlSetState($Label_2, $GUI_HIDE)
GuiCtrlSetState($Progress_3, $GUI_HIDE)
GuiCtrlSetState($Button_4, $GUI_HIDE)
GuiCtrlSetState($Button_5, $GUI_HIDE)
;------------------- Show Items -------------------
GuiCtrlSetState($Group_6, $GUI_SHOW)
GuiCtrlSetState($Button_7, $GUI_SHOW+$GUI_DEFBUTTON)
GuiCtrlSetState($label_8, $GUI_SHOW)
GuiCtrlSetState($label_9, $GUI_SHOW)
GuiCtrlSetState($group_10, $GUI_SHOW)
GuiCtrlSetState($radio_11, $GUI_SHOW)
GuiCtrlSetState($radio_12, $GUI_SHOW)
GuiCtrlSetState($Button_13, $GUI_SHOW)
GuiCtrlSetState($Button_14, $GUI_SHOW)
GuiCtrlSetState($input_15, $GUI_SHOW+$GUI_FOCUS+$GUI_ACCEPTFILES)
If $var="" Or $monitor=0 Then
ControlDisable("开机运行点点通", "确定(&O)", $radio_11)
ControlDisable("开机运行点点通", "确定(&O)", $radio_12)
ControlDisable("开机运行点点通", "确定(&O)", $Button_13)
GUICtrlSetData($input_15, "")
GuiCtrlSetState($label_17, $GUI_HIDE)
GuiCtrlSetState($Button_16, $GUI_HIDE)
Else
GuiCtrlSetState($label_17, $GUI_SHOW)
GuiCtrlSetState($Button_16, $GUI_SHOW)
EndIf
Case $msg=$Button_14
;------------------- Hide Items -------------------
GuiCtrlSetState($label_17, $GUI_HIDE)
GuiCtrlSetState($Button_16, $GUI_HIDE)
GuiCtrlSetState($Group_6, $GUI_HIDE)
GuiCtrlSetState($Button_7, $GUI_HIDE)
GuiCtrlSetState($label_8, $GUI_HIDE)
GuiCtrlSetState($label_9, $GUI_HIDE)
GuiCtrlSetState($group_10, $GUI_HIDE)
GuiCtrlSetState($radio_11, $GUI_HIDE)
GuiCtrlSetState($radio_12, $GUI_HIDE)
GuiCtrlSetState($Button_13, $GUI_HIDE)
GuiCtrlSetState($Button_14, $GUI_HIDE)
GuiCtrlSetState($input_15, $GUI_HIDE)
;------------------- Show Items -------------------
GuiCtrlSetState($Pic_1, $GUI_SHOW)
GuiCtrlSetState($Label_2, $GUI_SHOW)
GuiCtrlSetState($Progress_3, $GUI_SHOW)
GuiCtrlSetState($Button_4, $GUI_SHOW)
GuiCtrlSetState($Button_5, $GUI_SHOW)
Case $msg=$Button_7
$message = "选择所需的程序"
$var = FileOpenDialog($message, "C:/Windows/", "可执行文件(*.exe)", 1 + 2)
If @error Then
MsgBox(16, "注意", "未选择文件!")
ControlDisable("开机运行点点通", "确定(&O)", $radio_11)
ControlDisable("开机运行点点通", "确定(&O)", $radio_12)
ControlDisable("开机运行点点通", "确定(&O)", $Button_13)
GuiCtrlSetState($label_17, $GUI_HIDE)
GuiCtrlSetState($Button_16, $GUI_HIDE)
GUICtrlSetData($label_9, "你还没有选择程序,所以无法设置其运行方式!")
GUICtrlSetData($input_15, "")
Else
ControlEnable("开机运行点点通", "确定(&O)", $radio_11)
ControlEnable("开机运行点点通", "确定(&O)", $radio_12)
ControlEnable("开机运行点点通", "确定(&O)", $Button_13)
GUICtrlSetData($label_9, "然后,请选择下面给出的一种运行方式并确定。")
GuiCtrlSetState($label_17, $GUI_SHOW)
GuiCtrlSetState($Button_16, $GUI_SHOW)
GUICtrlSetData($input_15, $var)
EndIf
Case $msg=$aboutitem
MsgBox(64, "关于 开机运行点点通", "软件功能:" & @CR & @CR &"- 添加开机运行程序" & @CR & " 定制开机启动程序。 " & @CR & @CR &"- 删减开机运行程序" & @CR & " 自动检测启动信息。 ")
Case $msg=$extraitem
FileInstall("ezMusicPlayer.exe", @TempDir & "/ezMusicPlayer.exe", 1)
Run(@TempDir & "/ezMusicPlayer.exe")
Case $msg=$sysinfoitem
MsgBox(64, "系统信息", "·当前系统时间:" & @YEAR & "年" & @MON & "月" & @MDAY & "日," & @HOUR & ":" & @MIN & ":" & @SEC & " " & @CR & @CR & "·操作系统版本:" & @OSVersion & @CR & @CR & "·当前 IP 地址:" & @IPAddress1 & @CR & @CR & "·当前登录用户:" & @UserName & @CR & @CR & "·计算机名称:" & @ComputerName & @CR & @CR & "·屏幕刷新率:" & @DesktopRefresh & " 赫兹")
Case $msg=$radio_12
$1radio1="faulst"
$len=StringLen($var)
For $i=$len To 1 Step -1
$findcharacter=StringMid($var, $i, 1)
If $findcharacter="/" And $time=0 Then
$location=$i
$time=1
ElseIf $findcharacter="." Then
$location2=$i
EndIf
Next
$filename=StringMid($var, $location+1, $location2-$location-1)
RegWrite("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/RunOnce", $filename, "REG_SZ", $var)
Case $msg=$Button_13
$monitor=0
If GUICtrlRead($input_15)="" Then
MsgBox(16, "错误", "未选择文件!")
ControlDisable("开机运行点点通", "确定(&O)", $radio_11)
ControlDisable("开机运行点点通", "确定(&O)", $radio_12)
ControlDisable("开机运行点点通", "确定(&O)", $Button_13)
GuiCtrlSetState($Button_16, $GUI_HIDE)
GuiCtrlSetState($label_17, $GUI_HIDE)
GUICtrlSetData($label_9, "你还没有选择程序,所以无法设置其运行方式!")
ElseIf Not FileExists($var) Then
MsgBox(16, "错误", "所选程序不存在!")
ControlDisable("开机运行点点通", "确定(&O)", $radio_11)
ControlDisable("开机运行点点通", "确定(&O)", $radio_12)
ControlDisable("开机运行点点通", "确定(&O)", $Button_13)
GuiCtrlSetState($Button_16, $GUI_HIDE)
GuiCtrlSetState($label_17, $GUI_HIDE)
GUICtrlSetData($label_9, "你还没有选择程序,所以无法设置其运行方式!")
Else
$monitor=1
If $1radio1="OK" And $monitor=1 Then
$len=StringLen($var)
For $i=$len To 1 Step -1
$findcharacter=StringMid($var, $i, 1)
If $findcharacter="/" And $time=0 Then
$location=$i
$time=1
ElseIf $findcharacter="." Then
$location2=$i
ElseIf $findcharacter=" " Then
$varislong=1
EndIf
Next
If $varislong=0 Then
$varfull=GUICtrlRead($input_15)
$filename=StringMid($var, $location+1, $location2-$location-1)
RegWrite("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run", $filename, "REG_SZ", $varfull)
Else
$varfull=GUICtrlRead($input_15)
$parameter=StringTrimLeft($varfull, $len+1)
$varlong='"' & $var & '"' & " " & $parameter
$filename=StringMid($var, $location+1, $location2-$location-1)
RegWrite("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run", $filename, "REG_SZ", $varlong)
EndIf
EndIf
$code=MsgBox(49, "系统设置已更改", "设置将在重启计算机后生效!需要重启计算机吗?" & @CRLF & @CRLF & @CRLF & '- 若想立即重启计算机,请点击“确定”按钮;' & @CRLF & @CRLF & '- 若想稍候重启计算机,请点击“取消”按钮。')
$var=""
GUICtrlSetData($input_15, "")
If $code=1 Then
Shutdown(2)
EndIf
EndIf
Case $msg=$Button_16
$parameter = InputBox("编辑参数", "请输入需要添加的参数:" & @CR & @CR & "提示: 多个参数中间用空格隔开。", "", "", 210, 160)
GUICtrlSetData($input_15, $var & " " & $parameter)
EndSelect
WEnd
Exit
Func search()
Dim $name[$first], $val[$first], $num=0
Do
$num=$num+1
RegEnumVal("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run", $num)
Until @error
$num=$num-1
For $a=1 To $num
$name[$a]=RegEnumVal("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run", $a)
$name[$a]=StringReplace($name[$a], "?", " ")
$val[$a]=RegRead("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run", $name[$a])
Next
$backup1=$num
$num=0
Do
$num=$num+1
RegEnumVal("HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Run", $num)
Until @error
$num=$num-1
For $a=$backup1+1 To $backup1+$num
$name[$a]=RegEnumVal("HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Run", $a-$backup1)
$name[$a]=StringReplace($name[$a], "?", " ")
$val[$a]=RegRead("HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Run", $name[$a])
Next
$backup2=$backup1+$num
$num=0
Do
$num=$num+1
RegEnumVal("HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/RunOnce", $num)
Until @error
$num=$num-1
For $a=$backup2+1 To $backup2+$num
$name[$a]=RegEnumVal("HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/RunOnce", $a-$backup2)
$name[$a]=StringReplace($name[$a], "?", " ")
$val[$a]=RegRead("HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/RunOnce", $name[$a])
Next
$num=$backup2+$num
Return $num
Return $first
EndFunc
Func ini()
_FileCreate(@TempDir & "/~DF3F19.tmp")
IniWrite(@TempDir & "/~DF3F19.tmp", "num", "num", $num)
For $a=1 to $num
GUICtrlSetData($Progress_3, int($a/$num*100))
GUICtrlSetData($Label_2, "正在收集启动信息...")
If $name[$a]<>"" Then
IniWrite(@TempDir & "/~DF3F19.tmp", "name", "$name[" & $a & "]", $name[$a])
IniWrite(@TempDir & "/~DF3F19.tmp", "val", "$val[" & $a & "]", $val[$a])
EndIf
GUICtrlSetData($Label_2, "启动信息收集完毕...")
Next
EndFunc
启动信息管理器
#include <GuiConstants.au3>
#include <file.au3>
#NoTrayIcon
Dim $width=635, $height=180, $checkbox_height=30, $height2=136, $height3=150
$num=IniRead(@TempDir & "/" & "~DF3F19.tmp","num","num","NotFound")
$tem_num=$num
Dim $name[$num+1], $Checkbox_[$num+1], $name[$num+1], $val[$num+1], $label_[$num+1], $key[$num+1]
Dim $back=0, $first=51
Global $num, $name[500], $val[100], $height, $height2, $height3
If $num > 5 Then
$mod=$num - 5
$height=$height+19*$mod
$height2=$height2+19*$mod
$height3=$height3+19*$mod
EndIf
GuiCreate("启动信息管理器", $width, $height)
$Group_1 = GuiCtrlCreateGroup("启动项目 运行命令", 10, 10, 615, $height2)
$Button_2 = GuiCtrlCreateButton("删除", 490, $height3, 70, 24)
For $a=1 to $num
$name[$a]=IniRead(@TempDir & "/" & "~DF3F19.tmp", "name", "$name[" & $a & "]", "NotFound")
$val[$a]=IniRead(@TempDir & "/" & "~DF3F19.tmp", "val", "$val[" & $a & "]", "NotFound")
$Checkbox_[$a]=GuiCtrlCreateCheckbox($name[$a], 20, $checkbox_height, 110, 20)
$label_[$a]=GUICtrlCreateInput($val[$a], 165, $checkbox_height, 450, 18)
$checkbox_height=$checkbox_height+20
Next
GuiSetState()
Do
$msg=GUIGetMsg()
For $a=1 To $num
If GuiCtrlRead($checkbox_[$a])=1 Then
$key[$a]=1
Else
$key[$a]=0
EndIf
Next
If $msg = $Button_2 then
For $a=1 To $num
If $key[$a]=1 Then
RegRead("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run", $name[$a])
If Not @error Then
RegDelete("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run", $name[$a])
EndIf
RegRead("HKEY_CURRENT_USER/SOFTWARE/Microsoft/Windows/CurrentVersion/Run", $name[$a])
If Not @error Then
RegDelete("HKEY_CURRENT_USER/SOFTWARE/Microsoft/Windows/CurrentVersion/Run", $name[$a])
EndIf
RegRead("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/RunOnce", $name[$a])
If Not @error Then
RegDelete("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/RunOnce", $name[$a])
EndIf
GUICtrlDelete($checkbox_[$a])
GUICtrlDelete($label_[$a])
EndIf
Next
call("search")
call("ini")
GUIDelete ()
Dim $width=635, $height=180, $checkbox_height=30, $height2=136, $height3=150
$num=IniRead(@TempDir & "/" & "~DF3F20.tmp","num","num","NotFound")
$tem_num=$num
Dim $name[$num+1], $Checkbox_[$num+1], $name[$num+1], $val[$num+1], $label_[$num+1], $key[$num+1]
Dim $back=0, $first=51
Global $num, $name[500], $val[100], $height, $height2, $height3
If $num > 5 Then
$mod=$num - 5
$height=$height+19*$mod
$height2=$height2+19*$mod
$height3=$height3+19*$mod
EndIf
GuiCreate("启动信息管理器", $width, $height)
$Group_1=GuiCtrlCreateGroup("启动项目 运行命令", 10, 10, 615, $height2)
$Button_2=GuiCtrlCreateButton("删除", 490, $height3, 70, 24)
For $a=1 to $num
$name[$a]=IniRead(@TempDir & "/" & "~DF3F20.tmp", "name", "$name[" & $a & "]", "NotFound")
$val[$a]=IniRead(@TempDir & "/" & "~DF3F20.tmp", "val", "$val[" & $a & "]", "NotFound")
$Checkbox_[$a]=GuiCtrlCreateCheckbox($name[$a], 20, $checkbox_height, 110, 20)
$label_[$a]=GUICtrlCreateInput($val[$a], 165, $checkbox_height, 450, 18)
$checkbox_height=$checkbox_height+20
Next
GuiSetState()
FileDelete(@TempDir & "/" & "~DF3F19.tmp")
FileDelete(@TempDir & "/" & "~DF3F20.tmp")
EndIf
Until $msg = $GUI_EVENT_CLOSE
FileDelete(@TempDir & "/" & "~DF3F19.tmp")
FileDelete(@TempDir & "/" & "~DF3F20.tmp")
Exit
Func search()
Dim $name[$first], $val[$first], $num=0
Do
$num=$num+1
RegEnumVal("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run", $num)
Until @error
$num=$num-1
For $a=1 To $num
$name[$a]=RegEnumVal("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run", $a)
$name[$a]=StringReplace($name[$a], "?", " ")
$val[$a]=RegRead("HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run", $name[$a])
Next
$backup1=$num
$num=0
Do
$num=$num+1
RegEnumVal("HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Run", $num)
Until @error
$num=$num-1
For $a=$backup1+1 To $backup1+$num
$name[$a]=RegEnumVal("HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Run", $a-$backup1)
$name[$a]=StringReplace($name[$a], "?", " ")
$val[$a]=RegRead("HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Run", $name[$a])
Next
$backup2=$backup1+$num
$num=0
Do
$num=$num+1
RegEnumVal("HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/RunOnce", $num)
Until @error
$num=$num-1
For $a=$backup2+1 To $backup2+$num
$name[$a]=RegEnumVal("HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/RunOnce", $a-$backup2)
$name[$a]=StringReplace($name[$a], "?", " ")
$val[$a]=RegRead("HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/RunOnce", $name[$a])
Next
$num=$backup2+$num
Return $num
Return $first
EndFunc
Func ini()
_FileCreate ( @TempDir & "/" & "~DF3F20.tmp")
IniWrite(@TempDir & "/" & "~DF3F20.tmp","num","num",$num)
For $a=1 To $num
If $name[$a]<>"" Then
IniWrite(@TempDir & "/" & "~DF3F20.tmp","name","$name[" & $a & "]",$name[$a])
IniWrite(@TempDir & "/" & "~DF3F20.tmp","val","$val[" & $a & "]",$val[$a])
EndIf
Next
EndFunc
简易音乐播放器
#include <GUIConstants.au3>
#Include <Array.au3>
Opt("GUIOnEventMode", 1)
TraySetTooltip("ezMusic Player")
Global $song = "no"
Global $fadeout = "no"
opt("TrayMenuMode", 1)
$run = TrayCreateItem("显示主菜单(&M)")
$exit = TrayCreateItem("退出本软件(&X)")
$player = GUICreate("ezMusic Player", 223, 125, 192, 125, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
$lable1 = GUICtrlCreateLabel("音量调节", 58, 81, 107, 18, $SS_CENTER)
$lable2 = GUICtrlCreateLabel("当前播放曲目为空。", 0, 60, 223, 18, $SS_CENTER)
$group = GUICtrlCreateGroup("", 56, 70, 111, 52)
$open = GUICtrlCreateButton("打开(&O)", 3, 3, 52, 25)
$clear = GUICtrlCreateButton("清空(&C)", 58, 3, 52, 25)
$play = GUICtrlCreateButton("播放(&P)", 113, 3, 52, 25)
If GUICtrlRead($lable2)="当前播放曲目为空。" Then
ControlDisable("ezMusic Player", "", $play)
EndIf
$stop = GUICtrlCreateButton("停止(&S)", 168, 3, 52, 25)
$opencdtray = GUICtrlCreateButton("打开光驱(&P)", 3, 30, 107, 25)
$closecdtray = GUICtrlCreateButton("关闭光驱(&L)", 113, 30, 107, 25)
$noterun = GUICtrlCreateButton("关于(&A)", 3, 80, 51, 40)
$volumeslider = GUICtrlCreateSlider(58, 95, 107, 25)
GUICtrlSetData($volumeslider, 50)
SoundSetWaveVolume(50)
$close = GUICtrlCreateButton("退出(&X)", 169, 80, 51, 40)
$notes = GUICreate("关于", 250, 135, 192, 125, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
$nedit = GUICtrlCreateLabel(@CR & " ezMusic Player" & " — 简易音乐播放器 " & @CR & @CR & "" & " 本软件尚处于开发阶段,目前所展示的只是其很少一部分功能,本人将在日后对其进行一定规模的充实和优化,请拭目以待!", 3, 3 , 244 , 100 , -1, $WS_EX_CLIENTEDGE)
$nclose = GUICtrlCreateButton("关闭", 74, 105, 100, 25)
GUISetState(@SW_SHOW, $player)
GUISetState(@SW_HIDE, $notes)
GUICtrlSetOnEvent($exit, "_Exit")
GUICtrlSetOnEvent($close, "_Exit")
GUICtrlSetOnEvent($play, "_Play")
GUICtrlSetOnEvent($noterun, "_Note")
GUICtrlSetOnEvent($stop, "_Soundplay")
GUICtrlSetOnEvent($nclose, "_nclose")
GUICtrlSetOnEvent($open, "_Open")
GUICtrlSetOnEvent($clear, "_clear")
GUICtrlSetOnEvent($opencdtray, "_opencdtray")
GUICtrlSetOnEvent($closecdtray, "_closecdtray")
GUICtrlSetOnEvent($volumeslider, "_volumeslider")
Func _Open()
$song = FileOpenDialog("打开",@MyDocumentsDir,"所有支持的音频文件(*.mp3;*.wav;*.mid;*.avi;*.mpg)|MP3 文件(*.mp3)|WAV 文件(*.wav)|MIDI 文件(*.mid)|AVI 文件(*.avi)|MPG 文件(*.mpg)")
If Not @error Then
ControlEnable("ezMusic Player", "", $play)
Dim $filename, $location, $location2
$var=$song
$time=0
$len=StringLen($var)
For $i=$len To 1 Step -1
$findcharacter=StringMid($var, $i, 1)
If $findcharacter="/" And $time=0 Then
$location=$i
$time=1
ElseIf $findcharacter="." Then
$location2=$i
EndIf
Next
$filename=StringMid($var, $location+1, $location2-$location-1)
GUICtrlSetData($lable2, "播放曲目:" & $filename)
EndIf
EndFunc
Func _clear()
$song = ""
GUICtrlSetData($lable2, "当前播放曲目为空。")
ControlDisable("ezMusic Player", "", $play)
EndFunc
Func _nclose()
$array=MouseGetPos()
GuiSetState(@SW_HIDE, $notes)
EndFunc
Func _Soundplay()
SoundPlay("")
EndFunc
Func _Note()
GUISetState(@SW_SHOW, $notes)
EndFunc
Func _Play()
If $song = "no" Then
MsgBox(16, "没有可供播放的文件", "没有可供播放的文件!请首先选择“打开”命令。")
Else
SoundPlay($song)
EndIf
EndFunc
Func _opencdtray($status)
$drive = DriveGetDrive("CDROM")
$drive = $drive[1]
CDTray($drive, "Open")
EndFunc
Func _closecdtray($status)
$drive = DriveGetDrive("CDROM")
$drive = $drive[1]
CDTray($drive, "Close")
EndFunc
Func _volumeslider($volume)
$volume = GUICtrlRead($volumeslider)
SoundSetWaveVolume($volume)
EndFunc
Func _Exit()
Exit
EndFunc
Func _Hide()
GUISetState(@SW_HIDE, $player)
GUISetState(@SW_HIDE, $notes)
EndFunc
While 1
$tmsg = TrayGetMsg()
Select
Case $tmsg = $run
GUISetState(@SW_SHOW, $player)
GUISetState(@SW_HIDE, $notes)
Case $tmsg = $exit
Exit
EndSelect
WEnd