#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <ComboConstants.au3>
#include <GUIConstants.au3>
#include <GuiStatusBar.au3>
#include <EditConstants.au3>
#include <GuiTreeView.au3>
#include <TreeViewConstants.au3>
#include <StaticConstants.au3>
Opt("TrayIconHide", 1) ;隐藏托盘图标
Opt("GUICloseOnESC", 0) ;按下WSC键时,不停止程序运行
;主窗体
$Form = GUICreate("test", 520, 403, -1, -1)
$Top_Pic = GUICtrlCreatePic(@TempDir & "\logo.jpg", 0, 0, 520, 73)
$PageControl1 = GUICtrlCreateTab(1, 80, 520, 267)
$TabSheet1 = GUICtrlCreateTabItem("test")
$TabSheet2 = GUICtrlCreateTabItem("bak")
$Button4 = GUICtrlCreateButton("开始备份", 434, 282, 67, 25)
$Group3 = GUICtrlCreateGroup("备份设置", 231, 181, 280, 137)
$Path_bak = "C:\Program Files"
$Size = DirGetSize("C:\Program Files")
$GetTimer = FileGetTime($Path_bak, 0)
$Timer = $GetTimer[0] & "/" & $GetTimer[1] & "/" & $GetTimer[2] & " " & $GetTimer[3] & ":" & $GetTimer[4]
$Label2 = GUICtrlCreateLabel("上次备份时间:" & $Timer, 1, 327, 517, 18, 0x0300)
GUICtrlSetBkColor(-1, 0x007392E7)
$Input1 = GUICtrlCreateInput($Path_bak, 315, 231, 187, 22)
$Drivename = StringSplit($Path_bak, "")
$Label4 = GUICtrlCreateLabel("备份位置", 450, 210, 64, 18)
$Button3 = GUICtrlCreateButton("浏览(&O)", 240, 229, 67, 25)
$Label5 = GUICtrlCreateLabel("备份文件总大小:" & Round($Size / 1024 / 1024) & "MB", 240, 265, 231, 18)
$Label6 = GUICtrlCreateLabel("驱动器" & $Drivename[1] & "" & Round(DriveSpaceTotal($Path_bak), 0) & "MB" & " " & Round(DriveSpaceFree($Path_bak), 0) & "MB 可用", 240, 290, 230, 18)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet3 = GUICtrlCreateTabItem("test")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button4
$open = bak()
Case $Button3
$open = open()
EndSwitch
WEnd
;设置安装目录
Func open()
$Path_bak = FileSelectFolder("选择备份位置", "") ;显示一个文件夹选择对话框
If Not @error Then
If StringRight($Path_bak, 1) = "" Then ;StringRight为返回字符串中从右开始指定数量的字符
GUICtrlSetData($Input1, $Path_bak & "") ;GUICtrlSetData为修改指定控件的相关数据
Else
GUICtrlSetData($Input1, $Path_bak & "")
EndIf
EndIf
$Drivename = StringSplit($Path_bak, "")
$Label6 = GUICtrlCreateLabel("驱动器" & $Drivename[1] & "" & Round(DriveSpaceTotal($Path_bak), 0) & "MB" & " " & Round(DriveSpaceFree($Path_bak), 0) & "MB 可用", 240, 290, 180, 18)
$GetTimer = FileGetTime($Path_bak, 0)
$Timer = $GetTimer[0] & "/" & $GetTimer[1] & "/" & $GetTimer[2] & " " & $GetTimer[3] & ":" & $GetTimer[4]
$Label2 = GUICtrlCreateLabel("上次备份时间:" & $Timer, 1, 327, 516, 18, 0x0300)
GUICtrlSetBkColor(-1, 0x007392E7)
EndFunc ;==>open
Func bak()
RunWait('"' & @ComSpec & '" /c cmd', '', @SW_HIDE)
EndFunc ;==>bak