Function Reference

InetGet

Downloads a file from the internet using the http or ftp protocol.

InetGet ( "URL", "filename" [, reload [, background]] )

 

Parameters

URL URL of the file to download. See remarks below.
filename Local filename to download to.
reload [optional]
0 = (default) Get the file from local cache if available
1 = Forces a reload from the remote site
background [optional]
0 = (default) Wait until the download is complete before continuing.
1 = return immediately and download in the background (see remarks).

 

Return Value

Success: Returns 1.
Failure: Returns 0.

 

Remarks

Internet Explorer 3 or greater must be installed for this function to work.

The URL parameter should be in the form "http://www.somesite.com/path/file.html" - just like an address you would type into your web browser.

To use a username and password when connecting simply prefix the servername with "username:password@", e.g.
"http://myuser:mypassword@www.somesite.com"

The InetGet function works with http:// https:// and ftp:// - to change the transfer type when using ftp see the FtpBinaryMode option.

"background" Parameter

By default the function waits until the download has finished before returning. Sometimes with large downloads this is not always wanted. If the background parameter is set to 1 the function returns immediately and the download continues in the background. When in this mode two macros are used to keep track:
@InetGetActive = 1 while downloading, or 0 when finished.
@InetGetBytesRead = the number of bytes downloaded, or -1 if there has been an error.

Note, only one download can be active at once, if you call the function again before a download is complete it will fail.

To abort a download call the function with just the first parameter set to "abort" like so:

InetGet("abort")



 

Related

FtpBinaryMode (Option), FtpSetProxy, InetGetSize, HttpSetProxy

 

Example


InetGet("http://www.mozilla.org", "C:\foo.html")
InetGet("http://www.autoitscript.com", "C:\mydownload.htm", 1)
InetGet("ftp://ftp.mozilla.org/pub/mozilla.org/README", "README.txt", 1)


; Advanced example - downloading in the background
InetGet("http://www.nowhere.com/somelargefile.exe", "test.exe", 1, 1)

While @InetGetActive
  TrayTip("Downloading", "Bytes = " & @InetGetBytesRead, 10, 16)
  Sleep(250)
Wend

MsgBox(0, "Bytes read", @InetGetBytesRead)