本帖最後由 rictirse 於 2015-5-29 12:09 編輯
Windows 預設路徑修改器
適用 xp vista w7
- #include <GUIConstants.au3>
- Const $cnt = 18
- Global $Input[$cnt],$BUT_1[$cnt],$BUT_2[$cnt],$BUT_3[$cnt]
- Global $i,$Var
- Global $Height[2] = [20,25],$Width[5] = [70,400,25,50,50]
- Global $x[5] = [12,$Width[0]+20,$Width[0]+$Width[1]+25,$Width[0]+$Width[1]+$Width[2]+30,$Width[0]+$Width[1]+$Width[2]+$Width[3]+35],$y = 30
- Global $FormWidth = $x[4]+65, $FormHeight = 43+($cnt*$y)
- Global $FormName = "修改路徑"
- Global $GUI_BUT_Text[3] = ["...","Apply","Default"]
- Global $RegName[$cnt] = [ "AppData", "Cache", "Cookies", "Desktop", "Favorites", "History", "Local AppData", "Local Settings", "My Pictures", "NetHood", "Personal", "PrintHood", "Programs","Recent", "SendTo", "Start Menu", "Startup", "Templates"]
- Global $DefaultRoute[$cnt] = ["%USERPROFILE%Application Data", "%USERPROFILE%Local SettingsTemporary Internet Files", "%USERPROFILE%Cookies", "%USERPROFILE%桌面", "%USERPROFILE%Favorites", "%USERPROFILE%Local SettingsHistory", "%USERPROFILE%Local SettingsApplication Data", "%USERPROFILE%Local Settings", "%USERPROFILE%My DocumentsMy Pictures", "%USERPROFILE%NetHood", "%USERPROFILE%My Documents", "%USERPROFILE%PrintHood", "%USERPROFILE%「開始」功能表程式集", "%USERPROFILE%Recent", "%USERPROFILE%SendTo", "%USERPROFILE%「開始」功能表", "%USERPROFILE%「開始」功能表程式集啟動", "%USERPROFILE%Templates"]
- GUICreate ( $FormName, $FormWidth, $FormHeight, Default, Default,1)
- For $i=0 to $cnt-1
- GUICtrlCreateLabel ( $RegName[$i], $x[0], 13+($i*$y), $Width[0], $Height[0])
- $Input[$i] = GUICtrlCreateInput ( RegRead ( "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerShell Folders", $RegName[$i]), $x[1], 10+($i*$y), $Width[1], $Height[0])
- $BUT_1[$i] = GUICtrlCreateButton ( $GUI_BUT_Text[0], $x[2], 7+($i*$y), $Width[2], $Height[1])
- $BUT_2[$i] = GUICtrlCreateButton ( $GUI_BUT_Text[1], $x[3], 7+($i*$y), $Width[3], $Height[1])
- $BUT_3[$i] = GUICtrlCreateButton ( $GUI_BUT_Text[2], $x[4], 7+($i*$y), $Width[4], $Height[1])
- Next
- GUISetState (@SW_SHOW)
- WinSetOnTop ( $FormName, "", 1)
- While 1
- $nMsg = GUIGetMsg()
- For $i = 0 To $cnt-1
- If $nMsg = $BUT_1[$i] Then
- SelectFolder($i)
- EndIf
- If $nMsg = $BUT_2[$i] Then
- apply($i)
- EndIf
- If $nMsg = $BUT_3[$i] Then
- ReDefault($i)
- EndIf
- Next
-
- Switch $nMsg
- Case $GUI_EVENT_CLOSE
- Exit
- EndSwitch
- WEnd
- Func SelectFolder($i)
- WinSetOnTop ( $FormName, "", 0)
- $Var = FileSelectFolder ( "請選擇目錄", "", 1, RegRead ( "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerShell Folders", $RegName[$i]))
- WinWaitClose ( "瀏覽資料夾", "請選擇目錄")
- WinSetOnTop ( $FormName, "", 1)
- If $Var = "" Then
- Error1()
- GUICtrlSetData ( $Input[$i], RegRead ( "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerShell Folders", $RegName[$i]))
- Else
- If FileExists ($Var) = 1 Then
- GUICtrlSetData ( $Input[$i], $Var)
- Else
- Error2()
- EndIf
- EndIf
- EndFunc
- Func apply($i)
- If FileExists ($Var) = 1 Then
- RegWrite ( "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerUser Shell Folders", $RegName[$i],"REG_SZ", GUICtrlRead ($Input[$i]))
- Else
- Error2()
- Return
- EndIf
- Reboot()
- EndFunc
- Func ReDefault($i)
- RegWrite ( "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerUser Shell Folders", $RegName[$i], "REG_SZ", $DefaultRoute[$i])
- Reboot()
- EndFunc
- Func Reboot()
- GUISetState (@SW_HIDE)
- If MsgBox ( 36, $FormName,"已修改完成"&@CR&"重新啟動電腦後才會生效"&@CR&"是否馬上重新啟動") = 6 Then
- Shutdown (2)
- Else
- Exit
- EndIf
- EndFunc
- Func Error1()
- If @OSVersion = "WIN_VISTA" Or @OSVersion = "WIN_7" Then
- ToolTip (@CR&" 取消 "&@CR&" ")
- Else
- ToolTip (@CR&" 取消 "&@CR)
- EndIf
- Sleep (1500)
- ToolTip ( "")
- EndFunc
- Func Error2()
- If @OSVersion = "WIN_VISTA" Or @OSVersion = "WIN_7" Then
- ToolTip (@CR&" 路徑錯誤 "&@CR&" ")
- Else
- ToolTip (@CR&" 路徑錯誤 "&@CR)
- EndIf
- Sleep (1500)
- ToolTip ( "")
- EndFunc
複製代碼 |