V0.3 2008年6月1日
增加“在选项窗口的‘全选'、‘全取消'”的功能。
增加“在主窗口的将链接恢复到默认路径”的选项。
V0.2 2008年5月23日
增加“弹出式子窗口,用于添加项目并动态改变主窗口”的功能。
对更改过的路径,加深背景色突出显示。
V0.1 2008年5月23日
测试通过“我的文档,我的音乐,我的视频,我的收藏,我的桌面”的测试。
完成编程时动态增加选项功能。
#Region ;**** 参数创建于 AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\工具\3.2.11.0.1\Aut2Exe\Icons\ce.ico
#AutoIt3Wrapper_Outfile=个人文件夹设置工具.V0.3.exe
#AutoIt3Wrapper_Res_Comment=用于改变个人文件夹的路径,应用后请立即重新启动计算机。
#AutoIt3Wrapper_Res_Description=Alex作品
#AutoIt3Wrapper_Res_Fileversion=0.3.1.080601
#AutoIt3Wrapper_Res_LegalCopyright=Alexandrer King
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#CS 注册表路径 = HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
0 "AppData"=应用程序数据
1 "Cookies"=Cookies
2 "Desktop"=桌面
3 "Favorites"=收藏夹
4 "NetHood"=网上邻居,用于存贮添加到网上邻居中的其他计算机的快捷方式。
5 "Personal"=我的文档
6 "PrintHood"=打印机,用于存贮添加的打印机的快捷方式。
7 "Recent"=最近打开文件
8 "SendTo"=发送到
9 "Start Menu"=「开始」菜单
10 "Templates"=模板
11 "Programs"=「开始」菜单\\程序
12 "Startup"=「开始」菜单\\程序\\启动
13 "Local Settings"=Local Settings
14 "Local AppData"=Local Application Data
15 "Cache"=Internet缓存文件
16 "History"=历史
17 "My Pictures"=我的图片
18 "Fonts"=字体
19 "My Music"=我的音乐
20 "CD Burning"=CD Burning
21 "My Video"=我的视频
#CE
#include <GUIConstants.au3>
#include <Array.au3>
Opt("GUIOnEventMode", 1) ; 切换为OnEvent模式
;下面是变量定义
Local Const $AllItem = 22
Global $HomeDriver, $HomePath, $HomeEnvironment, $nNumber
Dim $aDict[3][$AllItem] = [["AppData", "Cookies", "Desktop", "Favorites", "NetHood", "Personal", _
"PrintHood", "Recent", "SendTo", "Start Menu", "Templates", "Programs", _
"Startup", "Local Settings", "Local AppData", "Cache", "History", _
"My Pictures", "Fonts", "My Music", "CD Burning", "My Video"],["应用程序", _
"Cookies", "桌面", "收藏夹", "网上邻居", "我的文档", "打印机", "最近打开", _
"发送到", "开始菜单", "模板", "程序", "启动", "本地设置", "本地数据", "缓存", _
"历史", "我的图片", "字体", "我的音乐", "CD 烧录", "我的视频"]]
Dim $aIndex[6] = ["2", "3", "5", "17", "19", "21"]
$nNumber = UBound($aIndex)
;用一个8×X的数组放置相关信息,这些信息自aDict数组由aIndex作为索引获得,本数组分别存放的是:项目名,中文,键值,LabelID,InputID,ChangeButtonID,新键值,DefaultButtonID
Dim $avArray[$nNumber][8]
Dim $Form_Main, $Form_Child, $Button_Apply
Dim $TempIndex[$AllItem]
;下面是GUI
MainGUI()
;下面是程序主体
While 1
Sleep(1000) ; 空循环
WEnd
;下面是子函数
Func MainGUI()
Local Const $mWidth = 641
Local $mHeight = 81 + $nNumber * 30
$HomeDriver = RegRead("HKEY_CURRENT_USER\Volatile Environment", "HOMEDRIVE")
$HomePath = RegRead("HKEY_CURRENT_USER\Volatile Environment", "HOMEPATH")
$HomeEnvironment = $HomeDriver & $HomePath
#Region ### START Koda GUI section ###
$Form_Main = GUICreate("个人文件夹设置 by Alexandrer King", $mWidth, $mHeight, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE")
GUISetFont(9, 800, 0, "微软雅黑")
$Label_Home = GUICtrlCreateLabel("当前用户的主路径:" & $HomeEnvironment, 10, 10, 520, 20)
For $Loop1 = 1 To $nNumber
$sTemp1 = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", $aDict[0][$aIndex[$Loop1 - 1]])
$avArray[$Loop1 - 1][0] = $aDict[0][$aIndex[$Loop1 - 1]]
$avArray[$Loop1 - 1][1] = $aDict[1][$aIndex[$Loop1 - 1]]
$avArray[$Loop1 - 1][2] = $sTemp1
$avArray[$Loop1 - 1][3] = GUICtrlCreateLabel($avArray[$Loop1 - 1][1], 10, 10 + 30 * $Loop1, 60, 20)
$avArray[$Loop1 - 1][4] = GUICtrlCreateInput($avArray[$Loop1 - 1][2], 70, 10 + 30 * $Loop1, 490, 20)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetBkColor(-1, 0xf0f0f0) ; 淡色
$avArray[$Loop1 - 1][5] = GUICtrlCreateButton("C", 570, 10 + 30 * $Loop1, 30, 20)
GUICtrlSetOnEvent(-1, "PointFolder")
$avArray[$Loop1 - 1][7] = GUICtrlCreateButton("D", 600, 10 + 30 * $Loop1, 30, 20)
GUICtrlSetOnEvent(-1, "PointDefault")
Next
$Button_Child = GUICtrlCreateButton("配置项目", 10, $mHeight - 40, 70, 25)
GUICtrlSetOnEvent(-1, "ChildGUI")
$Button_Apply = GUICtrlCreateButton("应用更改", 550, $mHeight - 40, 70, 25)
GUICtrlSetOnEvent(-1, "WriteREG")
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)
#EndRegion ### START Koda GUI section ###
EndFunc ;==>MainGUI
Func ChildGUI()
#CS ===================================================================
下面是常见的矩阵式排布算法:
XBase 距离坐标0,0的X轴基础坐标
YBase 距离坐标0,0的Y轴基础坐标
XOffset 控件的X轴尺寸+间距
YOffset 控件的Y轴尺寸+间距
Scale Y轴的行控制变量
Matrix 矩阵系数
positionX X轴坐标
positionY Y轴坐标
#CE ===================================================================
GUIDelete($Form_Main)
Local Const $Matrix = Round(Sqrt($AllItem), 0)
Local Const $XOffset = 90, $YOffset = 30
Local Const $XBase = 10, $YBase = 10
Local $Scale = 0
Local Const $cWidth = 481, $cHeight = 241
$Form_Child = GUICreate("选择要配置的项目", $cWidth, $cHeight, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "NewGUI")
GUISetFont(-1, 8, 400, 0, "微软雅黑")
GUICtrlCreateLabel("请在下面的列表中勾选需要配置的项目", 10, 15, 300, 20)
For $Loop4 = 1 To $AllItem
$positionX = $XBase + Mod(($Loop4 - 1), $Matrix) * $XOffset
If $positionX = $XBase Then
$Scale = $Scale + 1
EndIf
$positionY = $YBase + $Scale * $YOffset
$TempIndex[$Loop4 - 1] = GUICtrlCreateCheckbox($aDict[1][$Loop4 - 1], $positionX, $positionY, 90, 20)
Next
While UBound($aIndex)
GUICtrlSetState($TempIndex[_ArrayPop($aIndex)], $GUI_CHECKED)
WEnd
$Button_SelectAll = GUICtrlCreateButton("全选", $cWidth / 2 + 60, $cHeight - 40, 50, 25)
GUICtrlSetOnEvent(-1, "SelectAll")
$Button_UnselectAll = GUICtrlCreateButton("全取消", $cWidth / 2 - 110, $cHeight - 40, 50, 25)
GUICtrlSetOnEvent(-1, "UnselectAll")
$Button_ChildExit = GUICtrlCreateButton("确定", $cWidth / 2 - 30, $cHeight - 40, 60, 30)
GUICtrlSetOnEvent(-1, "NewGUI")
GUISetState(@SW_SHOW)
EndFunc ;==>ChildGUI
Func SelectAll()
For $Loop6 = 1 To $AllItem
GUICtrlSetState($TempIndex[$Loop6 - 1], $GUI_CHECKED)
Next
EndFunc ;==>SelectAll
Func UNselectAll()
For $Loop7 = 1 To $AllItem
GUICtrlSetState($TempIndex[$Loop7 - 1], $GUI_UNCHECKED)
Next
EndFunc ;==>UNselectAll
Func NewGUI()
Dim $aIndex[1]
For $Loop5 = 1 To $AllItem
If GUICtrlRead($TempIndex[$Loop5 - 1]) = $GUI_CHECKED Then
_ArrayAdd($aIndex, $Loop5 - 1)
EndIf
Next
If UBound($aIndex) = 1 Then
$yonc = MsgBox(0x1024, "注意", "您取消了 全部 的选项" & @CRLF & _
"这将使本程序没有可配置的项目" & @CRLF & _
"点 <是> 重新选择, 点 <否> 退出本程序.")
If $yonc = 6 Then
Return
Else
Exit
EndIf
EndIf
_ArrayDelete($aIndex, 0)
$nNumber = UBound($aIndex)
ReDim $avArray[$nNumber][8]
MainGUI()
GUIDelete($Form_Child)
EndFunc ;==>NewGUI
Func WriteREG()
For $Loop3 = 1 To $nNumber
If $avArray[$Loop3 - 1][6] <> "" Then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", $avArray[$Loop3 - 1][0], "REG_EXPAND_SZ", $avArray[$Loop3 - 1][6])
$avArray[$Loop3 - 1][6] = ""
GUICtrlSetBkColor($avArray[$Loop3 - 1][4], 0xf0f0f0) ; 淡色
EndIf
Next
GUICtrlSetState($Button_Apply, $GUI_DISABLE)
EndFunc ;==>WriteREG
Func PointFolder()
Local $iIndex, $sNEWFolder
$iIndex = _ArraySearch($avArray, @GUI_CtrlId, 0, 0, 0, 1, 1, 5)
$sNEWFolder = FileSelectFolder("指定新的位置", "", 7)
If Not @error Then
$avArray[$iIndex][6] = $sNEWFolder
GUICtrlSetData($avArray[$iIndex][4], $sNEWFolder)
GUICtrlSetBkColor($avArray[$iIndex][4], 0xd5f0f0) ; 淡色略深
GUICtrlSetState($Button_Apply, $GUI_Enable)
EndIf
EndFunc ;==>PointFolder
Func PointDefault()
Local $iIndex, $sNEWFolder
$iIndex = _ArraySearch($avArray, @GUI_CtrlId, 0, 0, 0, 1, 1, 7)
$sNEWFolder = RegRead("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", $avArray[$iIndex][0])
If Not @error Then
$sTempNEWFolder = StringReplace($sNEWFolder, "%USERPROFILE%", $HomeEnvironment)
$avArray[$iIndex][6] = $sTempNEWFolder
GUICtrlSetData($avArray[$iIndex][4], $sTempNEWFolder)
Else
$avArray[$iIndex][6] = ""
GUICtrlSetData($avArray[$iIndex][4], "")
EndIf
GUICtrlSetBkColor($avArray[$iIndex][4], 0xd5f0f0) ; 淡色略深
GUICtrlSetState($Button_Apply, $GUI_Enable)
EndFunc ;==>PointDefault
Func CLOSE()
Exit
EndFunc ;==>CLOSE
- screenshot2.png (30.95 KB)
-
2008-6-1 21:04
- 打包下载autotiPersonal.v0.3.b080601.rar