#region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_Icon=save.ico
#PRE_Outfile=收藏夹备份助手.exe
#PRE_Res_Comment=收藏夹备份助手
#PRE_Res_Description=收藏夹备份助手
#PRE_Res_Fileversion=2.0.0.0
#PRE_Res_LegalCopyright=Ado
#PRE_Res_File_Add=收藏夹备份助手.ini
#endregion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=E:\Downloads\Koda\收藏夹备份助手.kxf
Dim $ini, $path, $Name, $lnk
$ini = @ScriptDir & "" & StringTrimRight(@ScriptName, 3) & "ini"
Func _BackupFav($runexplorer = False)
DirRemove($path, 1)
DirCreate($path)
$Name = @YEAR & "年" & @MON & "月" & @MDAY & "日" & @HOUR & "时" & @MIN & "分" & @SEC & "秒"
RunWait(@ScriptDir & '\7z.exe' & ' a' & ' -tzip' & ' -mx9' & ' "' & $path & '\' & $Name & '.zip"' & ' "' & @FavoritesDir & '"', @WindowsDir, @SW_HIDE)
TrayTip("恭喜!", "收藏夹于 " & $Name & " 备份完成!", 5000)
If $runexplorer = True Then
Run("explorer.exe" & " " & $path)
EndIf
EndFunc ;==>_BackupFav
;带参数运行即自动备份
If $Cmdline[0] = 1 And $Cmdline[1] = "/b" Then
$path = IniRead($ini, "backup", "path", "")
If $path = "" Then
MsgBox(16, "错误!", "配置文件错误,请重新配置!")
Exit
EndIf
_BackupFav()
Exit
EndIf
;程序配置界面
$Form1 = GUICreate("收藏夹备份助手", 425, 105, -1, -1)
$Label1 = GUICtrlCreateLabel("备份文件保存目录", 8, 16, 100, 17)
$Input1 = GUICtrlCreateInput("", 112, 12, 241, 21)
$Button1 = GUICtrlCreateButton("浏览", 360, 8, 51, 25)
$Checkbox1 = GUICtrlCreateCheckbox("开机自动备份", 8, 40, 97, 17)
$Button2 = GUICtrlCreateButton("保存设置", 134, 64, 67, 25)
$Button3 = GUICtrlCreateButton("立即备份", 224, 64, 67, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
;读取配置文件
$path = IniRead($ini, "backup", "path", "")
If FileExists($path) Then
GUICtrlSetData($Input1, $path)
Else
GUICtrlSetData($Input1, "")
EndIf
;检查是否存在开始菜单启动项
$lnk = @StartupCommonDir & "" & StringTrimRight(@ScriptName, 3) & "lnk"
If FileExists($lnk) Then
GUICtrlSetState($Checkbox1, $GUI_CHECKED)
EndIf
;GUI消息循环
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$path = FileSelectFolder("选择保存目录", @ComputerName)
If @error <> 1 Then
GUICtrlSetData($Input1, $path)
EndIf
Case $Button2
$path = GUICtrlRead($Input1)
If $path = "" Then
MsgBox(16, "错误!", "请先选择保存目录!")
ElseIf Not FileExists($path) Then
MsgBox(16, "错误!", "目标目录不存在,程序将自动创建该目录!")
DirCreate($path)
Else
IniWrite($ini, "backup", "path", $path)
If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
FileCreateShortcut(@ScriptFullPath, $lnk, @ScriptDir, "/b")
Else
FileDelete($lnk)
EndIf
MsgBox(64, "恭喜!", "设置已保存!", 5)
EndIf
Case $Button3
$path = GUICtrlRead($Input1)
If $path = "" Then
MsgBox(16, "错误!", "请先选择保存目录!")
ElseIf Not FileExists($path) Then
DirCreate($path)
Else
_BackupFav(True)
EndIf
EndSwitch
WEnd