AcidCorps Posted July 21, 2007 Share Posted July 21, 2007 (edited) This is a little Download function I made for myself, it has a lot to it but the only variable that is not optional is the $sDownload everything else it automatically detected expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.5.0 (beta) Author: Acid Corps Title: Auto Download Script Function: Simplifies Downloading $sDownload = Link to file to download Format http://www.example.com/file.exe $sFilename = Name to save download file as (optional) Default: Original name from download link $sSize = Size of file to download (optional) Format: 100 or 100 KB or 100 MB or 100 GB If not stated attempts to use InetGetSize (does not always work) $sFolder = Folder to save file to (optional) Default: Script Directory Format: C:\My Folder $sProxy = Proxy to connect to the net (optional) Default: No Proxy Format: Proxy:Port 1 = Default Proxy $sName = Username for download (optional) For use with ftp and some http downloads $sPass = Password for download (optional) For use with ftp and some http downloads $sProgress = Progress bar on or off (optional) Default: On If you do not wish to use ,"", to omit variables then use ,0, and default will be used Usage: _Download($sDownload, $sFilename, $sSize, $sFolder, $sProxy, $sName, $sPass, $sProgress) #ce ---------------------------------------------------------------------------- Func _Download($sDownload, $sFilename=0, $sSize=0, $sFolder=0, $sProxy=0, $sName=0, $sPass=0, $sProgress=0) Opt("ExpandEnvStrings", 1) ; Setting Proxy If $sProxy = 1 Then HttpSetProxy(0) FtpSetProxy(0) EndIf If $sProxy <> 0 And $sProxy <> 1 And $sName <> 0 And $sPass <> 0 Then HttpSetProxy(2, $sProxy, $sName, $sPass) FtpSetProxy(2, $sProxy, $sName, $sPass) EndIf ; Setting Size If $sSize = 0 Then $ssSize = InetGetSize($sDownload) Else $ssSize = $sSize EndIf If StringRight($sSize, 2) = "kb" Then $sSizeTimes = 1024 If StringRight($sSize, 2) = "mb" Then $sSizeTimes = 1048576 If StringRight($sSize, 2) = "gb" Then $sSizeTimes = 1073741824 ; Finding Filename If $sFilename = 0 Then $ssFilename = StringTrimLeft($sDownload,StringInStr($sDownload,"/",1,-1)) Else $ssFileName = $sFileName EndIf ; Progress/Download If $sProgress = 0 then Dim $ssSize = InetGetSize($sDownload) INetGet($sDownload,$ssFilename) ProgressOn("Downloading...", "Retrieving new version.") While @InetGetActive Dim $p = (100 * @InetGetBytesRead) / $ssSize ProgressSet($p, @InetGetBytesRead & "/" & $ssSize & " bytes", "Download in progress.") Sleep(250) ProgressOff() WEnd Else InetGet($sDownload, $ssFilename) EndIf EndFunc Edit: Updated script with mrRevoked's method of finding the filename_Download.au3 Edited July 22, 2007 by AcidCorps Link to comment Share on other sites More sharing options...
jaenster Posted July 22, 2007 Share Posted July 22, 2007 Nice.. But still inetget -jaenster Link to comment Share on other sites More sharing options...
Pascal257 Posted July 22, 2007 Share Posted July 22, 2007 If StringRight($sSize, 2) = "kb" Then $sSizeTimes = 1024 If StringRight($sSize, 2) = "mb" Then $sSizeTimes = 1048576 If StringRight($sSize, 2) = "gb" Then $sSizeTimes = 1073741824What does this do? And why? Finding Filename If $sFilename = 0 Then $sFNArray = StringSplit($sDownload, "/") $sFNArrayAmount = $sFNArray[0] $ssFileName = $sFNArray[$sFNArrayAmount]This is a shorter method: StringTrimLeft($sDownload,StringInStr($sDownload,"/",1,-1)) greetings Pascal Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted July 22, 2007 Share Posted July 22, 2007 What does this do? And why?This is a shorter method:StringTrimLeft($sDownload,StringInStr($sDownload,"/",1,-1))greetingsPascalwhat if the file ends with "/" ? Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
AcidCorps Posted July 22, 2007 Author Share Posted July 22, 2007 (edited) What does this do? And why?It lets you use kb, mb, and gb, abbreviations in the $sSizeThis is a shorter method:StringTrimLeft($sDownload,StringInStr($sDownload,"/",1,-1))Updated Edited July 23, 2007 by AcidCorps Link to comment Share on other sites More sharing options...
ddshadow Posted July 30, 2007 Share Posted July 30, 2007 no progress bar no window is showed i use it like this $LINK="http://download.lavasoft.com/public/core.zip" _Download($LINK) Link to comment Share on other sites More sharing options...
ashley Posted July 30, 2007 Share Posted July 30, 2007 can u set it up so i will dwonload autoit... (lates version) all optinal stuff... cus i cant get it to work Free icons for your programs Link to comment Share on other sites More sharing options...
AcidCorps Posted July 31, 2007 Author Share Posted July 31, 2007 does anybody know where I went wrong with this code, I'm having some trouble trying to fix it Link to comment Share on other sites More sharing options...
ashley Posted July 31, 2007 Share Posted July 31, 2007 urm.. post an old one as well... and we will cross refrence... to check... Free icons for your programs Link to comment Share on other sites More sharing options...
AcidCorps Posted July 31, 2007 Author Share Posted July 31, 2007 Thats the only one I have, the only update is in a post above: StringTrimLeft($sDownload,StringInStr($sDownload,"/",1,-1) so I'm thinking it was buggy from the beginning and nobody noticed it till now. Link to comment Share on other sites More sharing options...
ashley Posted July 31, 2007 Share Posted July 31, 2007 Thats the only one I have, the only update is in a post above:StringTrimLeft($sDownload,StringInStr($sDownload,"/",1,-1)so I'm thinking it was buggy from the beginning and nobody noticed it till now.ok mae an excaple that downlaod autoit.exe... with all potinal stuff please Free icons for your programs Link to comment Share on other sites More sharing options...
AcidCorps Posted July 31, 2007 Author Share Posted July 31, 2007 (edited) _Download("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3.2.4.9-setup.exe","Autoit.exe","4.24 MB", @ScriptDir, 0, "AcidCorps", "AcidPass", 0)oÝ÷ Ùj.ÖÞÂ+ajYb°z0z÷«².Ö¶Ø^±©jÆ®¶seôF÷væÆöBgV÷C¶GG¢ò÷wwræWFöG67&Bæ6öÒö6vÖ&âövWFfÆRçÃöWFöC2öWFöB×c2ã"ãBã×6WGWæWRgV÷C² Edit:missed closing autoit tag Edited August 1, 2007 by AcidCorps Link to comment Share on other sites More sharing options...
ashley Posted July 31, 2007 Share Posted July 31, 2007 _Download("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3.2.4.9-setup.exe","Autoit.exe","4.24 MB", @ScriptDir, 0, "AcidCorps", "AcidPass", 0) Would be with all inputs However should act the same as [code]_Download("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3.2.4.9-setup.exe") ok no progress bar.. Free icons for your programs Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now