Jump to content

Download progressbar


Recommended Posts

Nevermind, I had to change the folder path. (to have the file extension there).

ProgressOn("Download", "Downloading...", "0%")
$url= "http://fuller.zen.co.uk/test/100MB_nonzero.bin" ;Set URL
$folder = @MyDocumentsDir & "\downloads\100mb.bin" ;Set folder
$hInet = InetGet($url, $folder, 1, 1) ;Forces a reload from the remote site and return immediately and download in the background
$FileSize = InetGetSize($url) ;Get file size
While Not InetGetInfo($hInet, 2) ;Loop until download is finished
    Sleep(500) ;Sleep for half a second to avoid flicker in the progress bar
    $BytesReceived = InetGetInfo($hInet, 0) ;Get bytes received
    $Pct = Int($BytesReceived / $FileSize * 100) ;Calculate percentage
    ProgressSet($Pct, $Pct & "%") ;Set progress bar
WEnd
ProgressOff()

The code does work :unsure:

Edited by gerwim
Link to comment
Share on other sites

  • 3 months later...

Nevermind, I had to change the folder path. (to have the file extension there).

ProgressOn("Download", "Downloading...", "0%")
$url= "http://fuller.zen.co.uk/test/100MB_nonzero.bin" ;Set URL
$folder = @MyDocumentsDir & "\downloads\100mb.bin" ;Set folder
$hInet = InetGet($url, $folder, 1, 1) ;Forces a reload from the remote site and return immediately and download in the background
$FileSize = InetGetSize($url) ;Get file size
While Not InetGetInfo($hInet, 2) ;Loop until download is finished
    Sleep(500) ;Sleep for half a second to avoid flicker in the progress bar
    $BytesReceived = InetGetInfo($hInet, 0) ;Get bytes received
    $Pct = Int($BytesReceived / $FileSize * 100) ;Calculate percentage
    ProgressSet($Pct, $Pct & "%") ;Set progress bar
WEnd
ProgressOff()

The code does work :mellow:

Tested the code works great mind if I use it for my own projects?

Is there a way to make the directory automatically as it needs one already setup to work also to make the download window movable when its downloading and have a cancel button?

Very new to autoit but very impressed so far with the bits of code around the place.

Going to want to flesh this out in a extended bit of code with replacing a file in a directory.

Edited by Revenger
Link to comment
Share on other sites

  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...