梦想吧技术论坛's Archiver

似水年华 发表于 2007-3-28 12:58 PM

DAEMON Tools 文件关联(小软件) AU3脚本

用Autoit写的
  1.可自动判断 Daemon Tools 的安装路径.
  2.可增加或删除要关联的文件类型(默认为10种,注意: 扩展名之间用 "|" 符号间隔)
  3.可以简单的更改文件关联的图标.
  4.可以随时关联或取消关联

By maxkingmax  

[code]#include <GUIConstants.au3>
fileinstall("cd.ico",@WindowsDir&"\ImageFile.ico",0)

if FileExists(@ProgramFilesDir&"\DAEMON Tools\daemon.exe") Then
        $filepath=@ProgramFilesDir&"\DAEMON Tools\daemon.exe"

elseif fileexists(@DesktopCommonDir&"\DAEMON Tools.lnk") then
        $path=filegetshortcut(@DesktopCommonDir&"\DAEMON Tools.lnk")
        $filepath=$path[0]
else
        if fileexists(@ProgramsCommonDir&"\DAEMON Tools\DAEMON Tools.lnk") Then
                $path=filegetshortcut(@ProgramsCommonDir&"\DAEMON Tools\DAEMON Tools.lnk")
                $filepath=$path[0]
        Else
                $var = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "DAEMON Tools")
                $num=stringinstr($var,"daemon.exe")
                $filepath=stringmid($var,2,$num+8)
        EndIf

EndIf
        
if $filepath = "" then
        $yon=Msgbox(0x1024,"注意","未找到 Daemon Tools 的安装路径. "&@CRLF&"可能未安装 Daemon Tools 或已经安装但本程序愚笨而未找到."&@CRLF&"如果确定已经安装, 请点击 <是> 进行手动指定, 否则点击 <否> 退出本程序.")
        if $yon=6 then
                $filepath=fileopendialog("指定 Daemon Tools 的安装位置",@ProgramFilesDir,"可执行程序(*.exe)",2,"DaemonTools.exe")
        else
                Exit
        EndIf
EndIf

$setuped=1
$iconfile=Regread("HKEY_CURRENT_USER\Software\Classes\Daemon Support Image\DefaultIcon","")
if $iconfile="" Then
        $iconfile=@WindowsDir&"\ImageFile.ico"
        $setuped=0
EndIf




#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Daemon Tools 映像文件关联器", 383, 173, 289, 166)
GUISetFont(9, 400, 0, "Tahoma")
$Group1 = GUICtrlCreateGroup(" Daemon Tools 主程序位置:", 8, 8, 369, 45)

$Input1 = GUICtrlCreateInput("", 16, 24, 353, 22, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
guictrlsetdata(-1,$filepath)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("退出(&X)", 304, 142, 73, 25, 0)

$Group2 = GUICtrlCreateGroup(' 指定要关联的文件类型(使用 "|" 符号进行分隔) ', 8, 56, 369, 49)

$Input2 = GUICtrlCreateInput(".cue|.iso|.bwt|.cdi|.b5t|.ccd|.msd|.nrg|.pgi|.vcd", 16, 72, 353, 22)

GUICtrlCreateGroup("", -99, -99, 1, 1)
$custumico = GUICtrlCreateButton("更改图标(&C)", 72, 139, 73, 25, 0)

$Label1 = GUICtrlCreateLabel("Maxkingmax", 160, 120, 69, 18, $SS_CENTER)

GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetCursor ($Label1, 0)
$Label2 = GUICtrlCreateLabel("赢政天下论坛", 208, 144, 76, 18)

GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetCursor ($Label2, 0)
$Button2 = GUICtrlCreateButton("关联(&O)", 304, 111, 73, 25, 0)
if $setuped=1 Then         Guictrlsetdata($button2,"取消关联(&C)")
$Group3 = GUICtrlCreateGroup("图标", 8, 110, 49, 57)

$Icon1 = GUICtrlCreateIcon($iconfile, 0, 16, 126, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        Exit
                Case $Label2
                        run(@COMSPEC&" /c Start [url]http://bbs.winzheng.com[/url]","",@SW_HIDE )
                Case $Label1
                        run(@COMSPEC&" /c Start mailto:Maxkingmax@gmail.com","",@SW_HIDE )
                case $custumico
                        $iconfile=FileOpenDialog("更改图标",@WindowsDir,"图标文件(*.ico)|动态链接库(*.dll)|可执行程序(*.exe)|所有文件(*.*)")
                        if @error Then
                        Else
                                GUICtrlSetImage ($Icon1 , $iconfile)
                        EndIf
                Case $Button2
                        $type=guictrlread($Input2)
                        $typelist = StringSplit($type,"|")
;~                         $i=1
;~                         for $a=1 to UBound($typelist)-1 step 1
;~                         msgbox(0,UBound($typelist)-1,$typelist[$i])
;~                         $i=$i+1
;~                         Next
                        
                                if $setuped=1 Then
                                        Regdelete ('HKEY_CURRENT_USER\Software\Classes\Daemon Support Image')
                                        $i=1
                                        for $a=1 to UBound($typelist)-1 step 1
                                                Regdelete('HKEY_CURRENT_USER\SOFTWARE\Classes\'&$typelist[$i],"")
;~                                                 msgbox(0,0,'HKEY_CURRENT_USER\SOFTWARE\Classes\'&$typelist[$i])
                                                $i=$i+1
                                        Next
                                        Guictrlsetdata($button2,"关联(&C)")
                                        $setuped=0
                                elseif $setuped=0 Then
;~                                         msgbox(0,$iconfile,$iconfile)
                                        RegWrite ('HKEY_CURRENT_USER\Software\Classes\Daemon Support Image\DefaultIcon',"","REG_SZ",$iconfile)
                                        RegWrite ('HKEY_CURRENT_USER\Software\Classes\Daemon Support Image\shell\Mount',"","REG_SZ","载入镜像(&O)")
                                        RegWrite ('HKEY_CURRENT_USER\Software\Classes\Daemon Support Image\shell\Mount\command',"","REG_SZ",'"'&$filepath&'"'&" -mount 0,"&'"'&"%1"&'"')
                                        RegWrite ('HKEY_CURRENT_USER\Software\Classes\Daemon Support Image\shell\unmount',"","REG_SZ","卸载镜像(&U)")
                                        RegWrite ('HKEY_CURRENT_USER\Software\Classes\Daemon Support Image\shell\unmount\command',"","REG_SZ",'"'&$filepath&'"'&" -unmount 0")
                                        $i=1
                                        for $a=1 to UBound($typelist)-1
                                        RegWrite ('HKEY_CURRENT_USER\SOFTWARE\Classes\'&$typelist[$i],"","REG_SZ","Daemon Support Image")
;~                                         msgbox(0,0,'HKEY_CURRENT_USER\SOFTWARE\Classes\'&$typelist[$i])
                                        $i=$i+1
                                        Next
                                        Guictrlsetdata($button2,"取消关联(&C)")
                                        $setuped=1
                                EndIf

EndSwitch
WEnd[/code]

页: [1]

Powered by Discuz! Archiver 7.0.0  © 2001-2009 Comsenz Inc.