找回密码
 加入
搜索
查看: 2157|回复: 9

求助,修改桌面路径的代码

[复制链接]
发表于 2009-5-31 14:08:47 | 显示全部楼层 |阅读模式
本帖最后由 破剑 于 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
发表于 2009-5-31 14:19:58 | 显示全部楼层
改一改就成了自己的东西?
 楼主| 发表于 2009-5-31 14:22:36 | 显示全部楼层
呵呵 盗版 盗版
发表于 2009-5-31 22:28:23 | 显示全部楼层
 $button5=GUICtrlCreateButton("程序默认设置(&1)",360,140,105,25)
        GUICtrlSetOnEvent($button5,"button5")
抄也不抄得细心点,就少了一句
发表于 2009-5-31 22:29:11 | 显示全部楼层
靠,测试代码。。。我还把自己的文件转移了!!!
发表于 2009-6-1 01:32:34 | 显示全部楼层
靠,测试代码。。。我还把自己的文件转移了!!!
lynfr8 发表于 2009-5-31 22:29


额。。。这么不小心啊。。。
下次我弄个删除系统文件的代码给你测试好了。。。
发表于 2009-6-1 01:35:16 | 显示全部楼层
以后测试代码还是放到沙盘安全一点
迟些搞个格式化硬盘的代码隐藏到几百行的代码里放上来让人测试
发表于 2009-6-1 06:29:06 | 显示全部楼层
看不懂,只看到 lynfr8 很“阴险”,嘿嘿,开个玩笑
发表于 2009-6-1 10:00:05 | 显示全部楼层
靠,测试代码。。。我还把自己的文件转移了!!!
lynfr8 发表于 2009-5-31 22:29

5楼是个热心人,随处可见他的帮助回复
 楼主| 发表于 2009-6-1 11:56:40 | 显示全部楼层
哈哈 谢谢 lynfr8 经过自己反复的对比代码 自己也发现是此处少了这个代码 加上后 一下就能用了 ,再次膜拜各位热心人。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-25 21:19 , Processed in 0.077637 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表