Jump to content

DL and progress bar


d4w
 Share

Go to solution Solved by benners,

Recommended Posts

#include <InetConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ProgressConstants.au3>

$hGUI = GUICreate("Download file", 489, 120, 190, 70)

$hStatus = _GUICtrlStatusBar_Create($hGUI, -1, "", $SBARS_TOOLTIPS)
Local $aParts[3] = [100, 200, -1]
_GUICtrlStatusBar_SetParts($hStatus, $aParts)
_GUICtrlStatusBar_SetText($hStatus, "DL progress...",0)

Local $idProgress, $hProgress
$idProgress = GUICtrlCreateProgress(0, 0, -1, -1, $PBS_SMOOTH)
$hProgress = GUICtrlGetHandle($idProgress)
_GUICtrlStatusBar_EmbedControl($hStatus, 2, $hProgress)

GUISetState(@SW_SHOW)

Local $TotalSize, $CalBytes, $Bytes, $size
$TotalSize = InetGetSize ("http://ipv4.download.thinkbroadband.com/50MB.zip")

Local $hDownload = InetGet("http://ipv4.download.thinkbroadband.com/50MB.zip", _
@DesktopDir & "\50MB.zip", $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)

$Timer = TimerInit()
Do
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
    $BytesRead = Round(InetGetInfo($hDownload, 0))
    $Percentage = Round(($BytesRead * 100 / $TotalSize))
    GUICtrlSetData($idProgress, $Percentage)
    ; Average download speed
    _GUICtrlStatusBar_SetText($hStatus, Round($BytesRead / 1024 / TimerDiff($Timer) * 1000) & " kb/s", 1)
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
If InetGetInfo($hDownload, 3) Then GUICtrlSetData($idProgress, 100)
InetClose($hDownload)

Do
Until GUIGetMsg() = -3

 

When the words fail... music speaks.

Link to comment
Share on other sites

23 hours ago, d4w said:

Appreciate some guidance with DLs with an embedded progress bar...

There is a nice UDF in the german forum. The authors are Oscar (his avatar name in the English forum is @Gorathan) and @UEZ .

Current version is from 19.09.2021. Some texts in the function headers are in german, but easy to translate with the help of e.g. Deepl.
There is also a sample script included, which offers some programs for testing the download process. 

https://autoit.de/thread/45697-downloadwithprogress/?pageNo=1

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
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
 Share

  • Recently Browsing   0 members

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