|
本帖最后由 破剑 于 2009-5-31 14:22 编辑
以下代码是修改论坛的修改桌面路径的代码 我加了一个程序默认的路径,但是在按按钮确无效,希望大家指导下。
#NoTrayIcon
#include <GUIConstants.au3>
#include <Process.au3>
#Include <GuiStatusBar.au3>
opt("GUIOnEventMode",1)
Global $button1,$button2,$button3,$button4,$button5,$button6,$reg1,$reg2,$reg3,$input1,$input2,$input3
Local $hIcons[2]
Local $aParts[2] = [130, 250]
$version = "桌面路径转移"
If WinExists($version) Then Exit
AutoItWinSetTitle($version)
$main=GUICreate("自定义个人设置",500,200,-1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "gui")
;status
$hStatus =_GUICtrlStatusBar_Create ($main)
_GUICtrlStatusBar_SetParts ($hStatus, $aParts)
_GUICtrlStatusBar_SetText ($hStatus, "Person-NewFolder")
_GUICtrlStatusBar_SetText ($hStatus, "By 破剑盗版的", 1)
;ico
$hIcons[0] = _WinAPI_LoadShell32Icon (21)
$hIcons[1] = _WinAPI_LoadShell32Icon (24)
_GUICtrlStatusBar_SetIcon ($hStatus, 0, $hIcons[0])
_GUICtrlStatusBar_SetIcon ($hStatus, 1, $hIcons[1])
main()
GuiSetState()
While 1
Sleep(200)
WEnd
Func main()
GUICtrlCreateGroup("自定义个人路径",5,5,390,170)
$reg1=RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\","Desktop")
$reg2=RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\","Personal")
$reg3=RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\","Favorites")
$button4=GUICtrlCreateButton("自定义设置(&S)",200,140,90,25)
GUICtrlSetOnEvent($button4,"button4")
$button5=GUICtrlCreateButton("程序默认设置(&1)",360,140,105,25)
GUICtrlCreateLabel("""桌面""文件夹:",15,35,105,-1)
$input1=GUICtrlCreateInput($reg1,120,32,205,20)
$button1=GUICtrlCreateButton("浏览...",330,32,50,20)
GUICtrlSetOnEvent($button1,"button1")
GUICtrlCreateLabel("""我的文档""文件夹:",15,70,105,-1)
$input2=GUICtrlCreateInput($reg2,120,67,205,20)
$button2=GUICtrlCreateButton("浏览...",330,67,50,20)
GUICtrlSetOnEvent($button2,"button2")
GUICtrlCreateLabel("""收藏""文件夹:",15,105,105,-1)
$input3=GUICtrlCreateInput($reg3,120,102,205,20)
$button3=GUICtrlCreateButton("浏览...",330,102,50,20)
GUICtrlCreateLabel("备注:只针对2K,XP系统有效",15,135,170,-1)
GUICtrlSetOnEvent($button3,"button3")
EndFunc
Func button1()
$var = FileSelectFolder("请选择新的""桌面""文件夹:", "",3,"d:\桌面")
if $var="" then $input1=$reg1
GUICtrlSetData($input1,$var)
EndFunc
Func button2()
$var = FileSelectFolder("请选择新的""我的文档""文件夹:", "",3,"d:\我的文档")
if $var="" then $input2=$reg2
GUICtrlSetData($input2,$var)
EndFunc
Func button3()
$var = FileSelectFolder("请选择新的""收藏""文件夹:", "",3,"d:\收藏")
if $var="" then $input3=$reg3
GUICtrlSetData($input3,$var)
if not FileExists($var&"\链接") then DirCreate($var&"\链接")
EndFunc
Func button4()
$desk=GUICtrlRead($input1,"")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\","Desktop","REG_EXPAND_SZ",$desk)
$folder=GUICtrlRead($input2,"")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\","Personal","REG_EXPAND_SZ",$folder)
$fav=GUICtrlRead($input3,"")
;msgbox(0,"a",$fav)
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\","Favorites","REG_EXPAND_SZ",$fav)
msgbox(64,"提示","自定义设置目录成功,注销或重启机器后生效!")
$rc = _RunDos("RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters")
if FileExists(@SystemDir&"\Userenv.dll") then DllCAll("Userenv.dll","int","RefreshPolicyEx","int",1,"int",1)
EndFunc
Func button5()
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\","Desktop","REG_EXPAND_SZ","D:\BACKUP\桌面")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\","Personal","REG_EXPAND_SZ","D:\My Documents")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\","Favorites","REG_EXPAND_SZ","D:\My Documents\Favorites")
msgbox(64,"提示","程序默认设置修改成功,注销或重启机器后生效!")
$rc = _RunDos("RunDll32.exe USER32.DLL,UpdatePerUserSystemParameters")
if FileExists(@SystemDir&"\Userenv.dll") then DllCAll("Userenv.dll","int","RefreshPolicyEx","int",1,"int",1)
EndFunc
Func gui()
if @GUI_CTRLID = $GUI_EVENT_CLOSE then
Exit
EndIf
EndFunc |
|