AutoIt file downloader script.

This is an AutoIt script I made that downloads files off the Internet. It works so well that I really ought to be using it more often.

$MyDocsFolder = “::{450D8FBA-AD25-11D0-98A8-0800361B1103}”
if $f=”” Then
$f=InputBox (“FileGet”, “Enter download URL: “)
$array = StringSplit($f, “/”)
$dir=FileSaveDialog ( “FileGet”, $MyDocsFolder, “All (*.*)”,2, $saved)
While @InetGetActive
TrayTip(“Downloading”, “Bytes = ” & @InetGetBytesRead, 10, 16)
MsgBox(4096, “Fileget Summary”, “URL entered: ” & $f & @CRLF & “File saved: ” & $saved & @CRLF & @InetGetBytesRead & ” bytes transferred”)

When you run the script, it checks the clipboard for the URL of the file to download, but if the clipboard is empty, you’ll be prompted for the location of the file.
The tricky part in making this script was figuring out how to isolate the file name from the rest of the URL. For example, if a user puts in the following address:

I needed to have the script isolate “autoit-v3-setup.exe” from the rest of the URL so its name can be used when the script downloads the file. This was accomplished using AutoIt’s StringSplit function, which splits a string into smaller substrings according to a specified delimiter. In this case the delimiter is the backslash character. The StringSplit function then creates an array that stores each substring. The first item of the array is the number of substrings stored, and the last item of the array contains the isolated file name.
Then the script opens the File Save dialog to prompt you for the destination folder for saving the file. The default location is the “My Documents” folder although you can save the file in a different folder. Afterwards it begins the download, keeping you posted on the progress from its icon in the system tray. When it’s done, it gives you a summary of what’s been transferred.
There’s no way VBScript can do this.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s