Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Date.au3>
- Func _DownloadWithProgress($sURL, $sFileName = "")
- ; -Author: name22 (www.autoit.de)
- Local $hDownload, $iSizeBytes = InetGetSize($sURL)
- Local $iH, $iM, $iS, $iTicks, $iCompletedBytes, $nPercent, $nElapsedTime, $nBPS, $nT = TimerInit()
- If $sFileName = "" Then
- $hDownload = InetGet($sURL, StringTrimLeft($sURL, StringInStr($sURL, "/", 0, -1)), 1, 1)
- Else
- $hDownload = InetGet($sURL, $sFileName, 0, 1)
- EndIf
- ProgressOn("Download", "0% Completed - 0 kB/s", "Remaining - 00:00:00", Default, Default, 18)
- Do
- $iCompletedBytes = InetGetInfo($hDownload, 0)
- $nPercent = $iCompletedBytes * 100 / $iSizeBytes
- $nElapsedTime = TimerDiff($nT) / 1000
- $nBPS = $iCompletedBytes / $nElapsedTime
- $iTicks = $iSizeBytes / $nBPS - $nElapsedTime
- $iH = Int($iTicks / 3600)
- $iTicks = Mod($iTicks, 3600)
- $iM = Int($iTicks / 60)
- $iS = Mod($iTicks, 60)
- ProgressSet($nPercent, "Remaining - " & StringFormat("%02d:%02d:%02d", $iH, $iM, $iS), StringFormat("%.1f", Round($nPercent, 1)) & "% Completed - " & Int($nBPS / 1024) & " kB/s")
- Sleep(50)
- Until InetGetInfo($hDownload, 2)
- ProgressSet(100, "", "Download completed.")
- ProgressOff()
- EndFunc ;==>_DownloadWithProgress
Add Comment
Please, Sign In to add comment