
Download ( $Link, $Downloadtype, $Directorytype, $Directoryname )
$Link examples :
http://www.dafont.com/top.php?page=1&nb_ppp=50
http://www.dafont.com/top.php?page=2&nb_ppp=50
http://cooltext.com/Fonts-3D
http://cooltext.com/Fonts-Modern
$Downloadtype examples :
1 = Download fonts and automatic extract zip files or copy tff files to Windows/Fonts/ folder.
2 = Just download fonts. ( Not extract or copy. )
$Directorytype examples :
1 = Installing all fonts in "Fonts" directory.
2 = Installing dafonts fonts in "Fonts" directory and cooltext fonts in "Fonts2" directory.
3 = Installing fonts in your choiced directory. ( $Directoryname )
Example : Download ("http://cooltext.com/Fonts-3D", 1, 2)
#include <GUIConstants.au3> #include <GuiEdit.au3> #include <INet.au3> #include <String.au3> #include <_ZipPlugin.au3> PluginOpen(@ScriptDir & "\Au3Zip.dll") $Form = GUICreate("Fonts Fetcher", 305, 385, 358, 329, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS)) $Input1 = GUICtrlCreateInput("www.dafont.com/top.php?page=1&nb_ppp=50", 48, 16, 241, 21) $Radio1 = GUICtrlCreateRadio("Download and install fonts.", 16, 48, 145, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetTip(-1, "Download fonts and automatic extract zip files or copy tff files to Windows/Fonts/ folder.") $Radio2 = GUICtrlCreateRadio("Just download fonts.", 176, 48, 113, 17) GUICtrlSetTip(-1, "Just download fonts. ( Not extract or copy. )") $Input2 = GUICtrlCreateInput("Fonts", 88, 96, 201, 21) GUICtrlSetState(-1, $GUI_DISABLE) $Button = GUICtrlCreateButton("Start", 8, 128, 289, 25) GUIStartGroup() $Label1 = GUICtrlCreateLabel("Link :", 16, 24, 30, 17) $Label2 = GUICtrlCreateLabel("Folder name :", 16, 104, 68, 17) GUIStartGroup() $Radio3 = GUICtrlCreateRadio("Dir type 1", 16, 72, 65, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetTip(-1, 'Installing all fonts in "Fonts" directory.') $Radio4 = GUICtrlCreateRadio("Dir type 2", 96, 72, 65, 17) GUICtrlSetTip(-1, 'Installing dafonts fonts in "Fonts" directory and cooltext fonts in "Fonts2" directory.') $Radio5 = GUICtrlCreateRadio("Dir type 3", 176, 72, 65, 17) GUICtrlSetTip(-1, 'Installing fonts in your choiced directory.') $Progress1 = GUICtrlCreateProgress(8, 360, 289, 17) $Edit = GUICtrlCreateEdit("", 8, 160, 289, 169) $Label3 = GUICtrlCreateLabel("", 8, 336, 289, 17) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Button GUICtrlSetState($Button, $GUI_DISABLE) $Par3 = "" If GUICtrlRead($Radio1) = $GUI_CHECKED Then $Par1 = 1 Else $Par1 = 2 EndIf If GUICtrlRead($Radio3) = $GUI_CHECKED Then $Par2 = 1 ElseIf GUICtrlRead($Radio4) = $GUI_CHECKED Then $Par2 = 2 Else $Par2 = 3 $Par3 = GUICtrlRead($Input2) EndIf $Var = Download(GUICtrlRead($Input1), $Par1, $Par2, $Par3) Write($Var[0] & " Fonts downloaded and installed in " & $Var[1] & " seconds.") GUICtrlSetState($Button, $GUI_ENABLE) Case $Radio3 GUICtrlSetState($Input2, $GUI_DISABLE) Case $Radio4 GUICtrlSetState($Input2, $GUI_DISABLE) Case $Radio5 GUICtrlSetState($Input2, $GUI_ENABLE) EndSwitch WEnd Func Download($Url, $Method = 1, $Dirtype = 1, $Dirtype3 = "") If $Dirtype = 3 Then $Dir = "\" & $Dirtype3 & "\" GUICtrlSetData($Label3, "Download starting...") Write("Download starting from " & $Url) $Timer = TimerInit() $Source = _INetGetSource($Url) If StringInStr($Url, "dafont.com") Then $String = _StringBetween($Source, 'href="http://img.dafont.com/download/?file=', '">Download<br>') $Urltype = 1 If $Dirtype <> 3 Then $Dir = "\Fonts\" ElseIf StringInStr($Url, "cooltext.com") Then $String = _StringBetween($Source, 'Download:<a href=Download/Font/', '>Click Here</a><br />') $Urltype = 2 If $Dirtype = 1 Then $Dir = "\Fonts\" ElseIf $Dirtype = 2 Then $Dir = "\Fonts2\" EndIf EndIf If Not FileExists(@ScriptDir & $Dir) Then DirCreate(@ScriptDir & $Dir) Dim $Var[UBound($String) + 1] For $i = 0 To UBound($String) - 1 If $Urltype = 1 Then If Not FileExists(@ScriptDir & $Dir & $String[$i] & ".zip") Then $Download = 'http://img.dafont.com/download/?file=' & $String[$i] InetGet($Download, @ScriptDir & $Dir & $String[$i] & ".zip") Write(@ScriptDir & $Dir & $String[$i] & ".zip downloaded.") EndIf ElseIf $Urltype = 2 Then If Not FileExists(@ScriptDir & $Dir & $String[$i]) Then $Download = 'http://cooltext.com/Download/Font/' & $String[$i] InetGet($Download, @ScriptDir & $Dir & $String[$i]) Write(@ScriptDir & $Dir & $String[$i] & " downloaded.") EndIf EndIf $Var[$i + 1] = $String[$i] $Calculate = Round((($i + 1) / UBound($String)) * 100, 0) GUICtrlSetData($Label3, "Downloading fonts (" & $i + 1 & " / " & UBound($String) & ") " & $Calculate & "%") GUICtrlSetData($Progress1, $Calculate) Next If $Method = 1 Then For $i = 1 To UBound($String) If $Urltype = 1 Then _ZipUnZip (@ScriptDir & $Dir & $Var[$i] & ".zip", @WindowsDir & "\Fonts\") ElseIf $Urltype = 2 Then If StringInStr($Var[$i], ".zip") Then _ZipUnZip (@ScriptDir & $Dir & $Var[$i], @WindowsDir & "\Fonts\") ElseIf StringInStr($Var[$i], ".ttf") Then FileCopy(@ScriptDir & $Dir & $Var[$i], @WindowsDir & "\Fonts\" & $Var[$i]) EndIf EndIf Next EndIf $Timerdiff = TimerDiff($Timer) GUICtrlSetData($Label3, "Download completed (" & UBound($String) & " / " & UBound($String) & ") " & $Calculate & "%") Dim $Var[2] = [UBound($String), Round($Timerdiff, 0) / 1000 ] Return $Var EndFunc ;==>Download Func Write($Data) If GUICtrlRead($Edit) = "" Then GUICtrlSetData($Edit, $Data) Else GUICtrlSetData($Edit, GUICtrlRead($Edit) & @CRLF & $Data) EndIf _GUICtrlEdit_LineScroll ($Edit, 0, _GUICtrlEdit_GetLineCount ($Edit)) EndFunc ;==>Write
Need _ZipPlugin.au3 and Au3Zip.dll for extract zip files. http://www.autoitscript.com/forum/index.ph...p;hl=_zipplugin
Attached Files
Edited by Jex, 18 November 2007 - 06:22 AM.







