Sign in to follow this  
Followers 0
ca143508

Download + Progress Bar

5 posts in this topic

This is what I have at the moment. Unfortunately the progress bar comes up but does not show the graphical filling. Is it that it downloads faster than the progress bar can re-calculate? Or is this a pipe dream???

Any help would be great.

Thanks,

Mike.

==========================================================

#include <GuiConstants.au3>

$DownloadNow = MsgBox(4,"My App","Would you like to download the latest update now?")

If $DownloadNow = 6 Then

Call("Download")

Else

Msgbox(0,"My App","The latest update will not be downloaded. The previous version will be opened.")

Run("OldFile.exe",2)

EndIf

Func Download()

InetGet("ftp://myserver/updatedfile.exe", "C:\Replacedfile.exe", 1, 1)

While @InetGetActive

$FileSize = InetGetSize("ftp://myserver/updatedfile.exe")

$filedownload = round(@InetGetBytesRead/1048576, 2)

$Percent = $filedownload/$FileSize

ProgressOn("My Download","")

ProgressSet($Percent,"Downloaded - " & $filedownload & " Mb")

;TrayTip("Downloading...", "Downloaded = " & $filedownload & " Mb", 10, 16)

Sleep(250)

Wend

ProgressOff()

EndFunc

============================================================

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

ive commented your code to show you where you went wrong

#include <GuiConstants.au3>
Note: this should be in support, i just noticed it wasn't
$DownloadNow = MsgBox(4,"My App","Would you like to download the latest update now?")
If $DownloadNow = 6 Then
    Download();you don't need to use call
Else
    Msgbox(0,"My App","The latest update will not be downloaded. The previous version will be opened.")
    Run("OldFile.exe",2)
EndIf

Func Download()
    ProgressOn("My Download","", "", -1, -1, 16);you must set progress on before loop
    InetGet("ftp://myserver/updatedfile.exe", , "C:\Replacedfile.zip", 1, 1)
    $FileSize = InetGetSize("ftp://myserver/updatedfile.exe", )/1048576;need to divide by 1048576 also, variables that don't change should be outside loop
    While @InetGetActive
        $filedownload = round(@InetGetBytesRead/1048576, 2)
        $Percent = Round(($filedownload/$FileSize)*100);need to mutliply by 10 to get percentage
        ProgressSet($Percent,"Downloaded - " & $filedownload & " Mb")
;TrayTip("Downloading...", "Downloaded = " & $filedownload & " Mb", 10, 16)
        Sleep(250)
    Wend
    ProgressOff()
EndFunc ;==>Download

Edited by RazerM

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

Sorry guys. I just realised this is in the wrong forum.

Share this post


Link to post
Share on other sites

This script rules. Thank you guys. This is just what the doctor ordered...

I needed something very straight and to the point for a script I am working on for a group of rather high maintenance users. All I needed was a method of download with a progress bar... no option to cancel download. RazorM's modification delivered exactly what I needed.

:) Thanks Dudes!

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