#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=include\系统清理工具.ico
#AutoIt3Wrapper_outfile=系统资料转移工具.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Comment=程序制作:鼎盛中国
#AutoIt3Wrapper_Res_Description=系统资料转移工具
#AutoIt3Wrapper_Res_Fileversion=1.6.8.8
#AutoIt3Wrapper_Res_LegalCopyright=All CopyRights Reserve By Cnds
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#Region AutoIt3Wrapper 预编译参数(常用参数)
#EndRegion AutoIt3Wrapper 预编译参数设置完成
#include <GUIConstantsEx.au3>
#include <buttonconstants.au3>
#include <WindowsConstants.au3>
#Include <Constants.au3>
#include <File.au3>
#include <GuiListBox.au3>
#Include <WinAPIEx.au3>
#cs ____________________________________
Au3 版本:3.3.6.1
脚本作者: 鼎盛中国
Email: smooth188@163.com
QQ/TM: 93737785
脚本版本: 1.1.0.8
脚本功能: 清理系统垃圾文件
#ce _______________脚本开始_________________
;
;禁止程序在桌面路径运行
If @ScriptDir = @DesktopDir Or @ScriptDir = @DesktopCommonDir Then
MsgBox(0,"错误","请勿将程序放在桌面运行", 3)
Exit
EndIf
;
Global $Desktoppath = "D:\Backup\桌面"
Global $Favoritespath = "D:\Backup\收藏夹"
Global $Personalpath = "D:\Backup\我的文档"
;
Global $Title = "系统资料转移工具"
If WinExists($Title) Then Exit
AutoItWinSetTitle($Title)
Global $Form = GUICreate($Title, 430, 250, -1, -1)
;加载图片
Global $Image = @TempDir & '\Logo.jpg'
FileInstall('include\Logo.jpg', $Image, 1)
GUICtrlCreatePic($Image, 150, 10, 268, 52, 0)
FileDelete($Image)
;
$Group1 = GUICtrlCreateGroup("", 10, 2, 120, 52)
$Group2 = GUICtrlCreateGroup("", 148, 2, 272, 62)
Dim $Checkbox[4]
Dim $Button[4]
$Button[1] = GUICtrlCreateButton("全部选择(&A)", 22, 16, 96, 30)
$Group3 = GUICtrlCreateGroup("C盘资料转移", 15, 75, 400, 120)
$Checkbox[1] = GUICtrlCreateCheckbox("把“桌面”转移到“D:\Backup\桌面”", 24, 96, 218, 20, $BS_RIGHTBUTTON)
$Checkbox[2] = GUICtrlCreateCheckbox("把“收藏夹”转移到“D:\Backup\收藏夹”", 24, 130, 242, 20, $BS_RIGHTBUTTON)
$Checkbox[3] = GUICtrlCreateCheckbox("把“我的文档”转移到“D:\Backup\我的文档”", 24, 160, 266, 20, $BS_RIGHTBUTTON)
$Button[2]= GUICtrlCreateButton("转移(&E)", 20, 210, 60, 25)
$Button[3]= GUICtrlCreateButton("恢复(&R)", 120, 210, 60, 25)
GUICtrlCreateLabel("程序制作:鼎盛中国", 280, 210, 108, 20)
GUICtrlCreateLabel("Email:smooth188@163.com", 280, 230, 180, 20)
;
GUISetState(@SW_SHOW) ;建议所有控件都建立完再显示 避免窗口重绘
;
Opt("TrayMenuMode",1) ; 默认托盘菜单项目(脚本已暂停/退出脚本) (Script Paused/Exit) 将不显示.
$prefsitem = TrayCreateItem("参数")
TrayCreateItem("")
$aboutitem = TrayCreateItem("关于")
TrayCreateItem("")
$exititem = TrayCreateItem("退出")
TraySetState()
;
Local $bTf = True
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
If MsgBox(4, "温馨提示", "退出程序并访问鼎盛中国网站吗?", 0, $Form) = 7 Then
Exit
Else
shellexecute("Http://hi.baidu.com/cnace")
Exit
EndIf
Case $Button[1]
If $bTf = True Then
GUICtrlSetData($Button[1], '全部取消(&C)')
For $i = 1 To 3
GUICtrlSetState($Checkbox[$i],$GUI_CHECKED)
Next
$bTf = False
Else
GUICtrlSetData($Button[1], '全部选择(&A)')
For $i = 1 To 3
GUICtrlSetState($Checkbox[$i],$GUI_UNCHECKED)
Next
$bTf = True
EndIf
Case $Button[2]
Dim $s = 0
For $c = 1 To 3
If GUICtrlRead($Checkbox[$c]) = $GUI_CHECKED Then
$s = 1
ExitLoop
EndIf
Next
If $s = 0 Then
$Msg = MsgBox(0, "温馨提示", "您未选择任何项目,请选择要执行的项目后再操作!", 0, $Form)
Else
;计算转移前C盘的可用空间
If NOT @error Then
$total = DriveSpaceFree("C:")
EndIf
For $m = 1 To 2
GUICtrlSetState($Button[$m],$GUI_DISABLE)
Next
For $i=1 To 3
GUICtrlSetState($Checkbox[$i],$GUI_DISABLE)
Next
_MainProgram();执行转移主程序
;计算转移后C盘的可用空间
Dim $result
If NOT @error Then
$totalsize = DriveSpaceFree("C:")
EndIf
$result = Abs(Round(($totalsize - $total), 2))
If MsgBox(4,"温馨提示", "资料转移完成,共为您释放了 " & $result & " MB的C盘空间^_^,是否退出程序?", 0, $Form) = 6 Then
shellexecute("Http://hi.baidu.com/cnace")
EXIT
Else
For $n = 1 To 3
GUICtrlSetState($Button[$n],$gui_enable)
Next
For $i=1 To 3
GUICtrlSetState($Checkbox[$i],$GUI_ENABLE)
GUICtrlSetState($Checkbox[$i],$GUI_UNCHECKED)
Next
Sleep(100)
GUICtrlSetData($Button[1], '全部选择(&A)')
EndIf
EndIf
Case $Button[3]
Dim $s = 0
For $c = 1 To 3
If GUICtrlRead($Checkbox[$c]) = $GUI_CHECKED Then
$s = 1
ExitLoop
EndIf
Next
If $s = 0 Then
$Msg = MsgBox(0, "温馨提示", "您未选择任何项目,请选择要执行的项目后再操作!", 0, $Form)
Else
;计算转移前C盘的可用空间
If NOT @error Then
$total = DriveSpaceFree("C:")
EndIf
For $m = 1 To 2
GUICtrlSetState($Button[$m],$GUI_DISABLE)
Next
For $i=1 To 3
GUICtrlSetState($Checkbox[$i],$GUI_DISABLE)
Next
_Recovery();执行恢复主程序
;计算转移后C盘的可用空间
Dim $result
If NOT @error Then
$totalsize = DriveSpaceFree("C:")
EndIf
$result = Abs(Round(($totalsize - $total), 2))
If MsgBox(4,"温馨提示", "恢复完成,共占用了 " & $result & " MB的C盘空间^_^,是否退出程序?", 0, $Form) = 6 Then
shellexecute("Http://hi.baidu.com/cnace")
EXIT
Else
For $n = 1 To 3
GUICtrlSetState($Button[$n],$gui_enable)
Next
For $i=1 To 3
GUICtrlSetState($Checkbox[$i],$GUI_ENABLE)
GUICtrlSetState($Checkbox[$i],$GUI_UNCHECKED)
Next
Sleep(100)
GUICtrlSetData($Button[1], '全部选择(&A)')
EndIf
EndIf
EndSwitch
$msg = TrayGetMsg()
Select
Case $msg = 0
ContinueLoop
Case $msg = $prefsitem
Msgbox(64, "参数:", "系统版本:" & @OSVersion)
Case $msg = $aboutitem
Msgbox(64, "关于:系统清理工具", "程序制作:鼎盛中国,2011年4月28日于上海")
Case $msg = $exititem
ExitLoop
EndSelect
WEnd
;
;
Func _MainProgram()
Dim $Checkboxcount[1]
$i = 1
For $j = 1 To 3 ;已知 有3个checkbox
If GUICtrlRead($Checkbox[$j]) = $GUI_Checked Then
ReDim $Checkboxcount[$i+1];修改新数组长度
$Checkboxcount[$i] = $j;在新数组中记录下需要执行的行
$i = $i + 1 ;计数
EndIf
Next
$i=$i-1
For $k = 1 To $i
_Work($Checkboxcount[$k]);执行这一条
Next
EndFunc
Func _Work($worknum)
Switch $worknum
Case 1
If @DesktopDir <> $Desktoppath Then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Desktop", "REG_EXPAND_SZ", $Desktoppath)
RunWait(@ComSpec & " /c taskkill /f /im explorer.exe", "", @SW_HIDE)
Run(@WindowsDir & "\explorer.exe", "", "")
Dirmove(@UserProfileDir & "\桌面", @UserProfileDir & "\桌面_rename")
Dirmove(@UserProfileDir & "\桌面_rename", $Desktoppath, 1)
EndIf
Case 2
If @FavoritesDir <> $Favoritespath Then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Favorites", "REG_EXPAND_SZ", $Favoritespath)
RunWait(@ComSpec & " /c taskkill /f /im explorer.exe", "", @SW_HIDE)
Run(@WindowsDir & "\explorer.exe", "", "")
Dirmove(@UserProfileDir & "\收藏夹", @UserProfileDir & "\收藏夹_rename")
Dirmove(@UserProfileDir & "\收藏夹_rename", $Favoritespath, 1)
EndIf
Case 3
If @MyDocumentsDir <> $Personalpath Then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Personal", "REG_EXPAND_SZ", $Personalpath)
RunWait(@ComSpec & " /c taskkill /f /im explorer.exe", "", @SW_HIDE)
Run(@WindowsDir & "\explorer.exe", "", "")
Dirmove(@UserProfileDir & "\My Documents", @UserProfileDir & "\My Documents_rename")
Dirmove(@UserProfileDir & "\My Documents_rename", $Personalpath, 1)
EndIf
EndSwitch
EndFunc
;
;恢复系统默认的路径
Func _Recovery()
Dim $Checkboxcount[1]
$i = 1
For $j = 1 To 3 ;已知 有3个checkbox
If GUICtrlRead($Checkbox[$j]) = $GUI_Checked Then
ReDim $Checkboxcount[$i+1];修改新数组长度
$Checkboxcount[$i] = $j;在新数组中记录下需要执行的行
$i = $i + 1 ;计数
EndIf
Next
$i=$i-1
For $k = 1 To $i
_Workcode($Checkboxcount[$k]);执行这一条
Next
EndFunc
Func _Workcode($worknum)
Switch $worknum
Case 1
If @DesktopDir = $Desktoppath Then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Desktop", "REG_EXPAND_SZ", "%USERPROFILE%\桌面")
RunWait(@ComSpec & " /c taskkill /f /im explorer.exe", "", @SW_HIDE)
Run(@WindowsDir & "\explorer.exe", "", "")
Dirmove($Desktoppath, $Desktoppath & "_rename")
Dirmove($Desktoppath & "_rename", @UserProfileDir & "\桌面", 1)
EndIf
Case 2
If @FavoritesDir = $Favoritespath Then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Favorites", "REG_EXPAND_SZ", "%USERPROFILE%\收藏夹")
RunWait(@ComSpec & " /c taskkill /f /im explorer.exe", "", @SW_HIDE)
Run(@WindowsDir & "\explorer.exe", "", "")
Dirmove($Favoritespath, $Favoritespath & "_rename")
Dirmove($Favoritespath & "_rename", @UserProfileDir & "\收藏夹", 1)
EndIf
Case 3
If @MyDocumentsDir = $Personalpath Then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", "Personal", "REG_EXPAND_SZ", "%USERPROFILE%\My Documents")
RunWait(@ComSpec & " /c taskkill /f /im explorer.exe", "", @SW_HIDE)
Run(@WindowsDir & "\explorer.exe", "", "")
Dirmove($Personalpath, $Personalpath & "_rename")
Dirmove($Personalpath & "_rename", @UserProfileDir & "\My Documents", 1)
EndIf
EndSwitch
EndFunc