Sign in to follow this  
Followers 0
gerwim

Download progressbar

3 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

I wanted to do a downloader, like this (just for fun), but i didnt have idea, how to do.So, thank you man! :graduated:

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0