Sign in to follow this  
Followers 0
DickG

Progress Bar update problem

3 posts in this topic

After researching and reading all the posts on this, I tried what looked like a good scheme. But the progress bar never gets updated. It pops up, downloads the file, then closes. I can't figure out what the problem is.

I am using FileGetSize() instead of @InetGetBytesRead because, as I understand it, @InetGetBytesRead will read whatever is coming down the pipe, not just the file I'm downloading. I usually have other things downloading, like torrents. I think that @InetGetBytesRead would read that too, right?

So I am trying to read the size of the file being downloaded, as it is being downloaded, to determine the Percent value. I can watch it grow in size in my file manager, so figured the FileGetSize() command would also do this. But who knows.

Either way, I tried both methods, and neither one updates the progress bar.

Here is my test code:

Dim $File, $Size
Global $Percent
    
;Download file.
$File="http://www.vantecusa.com/images/wallpaper4_large.jpg"
$Size = InetGetSize($File)
    
;Start progress bar.
ProgressOn ("Downloading ...", "")
ProgressSet(0, 0 & "%")
    
;Start adlib update.
AdlibEnable("UpdateProgressBar", 1000); update
    
;Start download.
InetGet($File, @ScriptDir & "\File.jpg", 1)
ProgressOff()
MsgBox(0,"Download complete", @ScriptDir & "\File.jpg")
    
;Stop adlib update
AdlibDisable()

Func UpdateProgressBar()
    $Percent = Int((FileGetSize(@ScriptDir & "\File.jpg") * 100)/$Size) 
    While $Percent < 100
         ProgressSet($Percent, $Percent & "%")
    WEnd
    ProgressOff()
EndFunc

Anyone have an idea of what my problem is?

Regards,

Dick

Share this post


Link to post
Share on other sites



Try it out:

DownloadProgeressBar("http://www.vantecusa.com/images/wallpaper4_large.jpg")
MsgBox(0,"Download complete", @ScriptDir & "\File.jpg")
   
Func DownloadProgeressBar($sFile)
    Local $iSize = InetGetSize($sFile)

    ProgressOn ("Downloading ...", "")
    InetGet($sFile, @ScriptDir & "\File.jpg", 1, 1)
    While @InetGetActive
        $iPercent = Int((@InetGetBytesRead/$iSize)*100)
        ProgressSet($iPercent, $iPercent & "%")
        Sleep(10)
    WEnd
    Sleep(500)
    ProgressOff()
EndFunc


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

Well I'll be damned! That works!!! I've got to study this to see what I did wrong. :-(

Thanks a bunch, Danny!!!

Dick

Try it out:

DownloadProgeressBar("http://www.vantecusa.com/images/wallpaper4_large.jpg")
MsgBox(0,"Download complete", @ScriptDir & "\File.jpg")
   
Func DownloadProgeressBar($sFile)
    Local $iSize = InetGetSize($sFile)

    ProgressOn ("Downloading ...", "")
    InetGet($sFile, @ScriptDir & "\File.jpg", 1, 1)
    While @InetGetActive
        $iPercent = Int((@InetGetBytesRead/$iSize)*100)
        ProgressSet($iPercent, $iPercent & "%")
        Sleep(10)
    WEnd
    Sleep(500)
    ProgressOff()
EndFunc

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