Hallo aflakes,
die Downloadspeed zeige ich in meinem kleinen Downloader-Beispiel mit an:
Spoiler anzeigen
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Date.au3>
#include <array.au3>
HttpSetUserAgent("Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.7) Gecko/20100713 Firefox/3.6.7") ; User-Agent (Header) von AutoIt3 ändern, da beim Webhoster dieser gesperrt ist
[/autoit] [autoit][/autoit] [autoit]Global $tDiff, $iToDo, $iRTime, $sMSG, $nKBPerSec
$sUrl = "http://translation.autoit.de/autoitinfo/hilfedateien/AutoIt-Hilfe-Deutsch-3.3.6.1-Stand-07_09_10.zip"
;url eventell gegen einen anderen größeren Download tauschen, dann aber bitte auch $sPath ändern
$sPath = @ScriptDir & "\AutoIt-Hilfe-Deutsch-3.3.6.1-Stand-07_09_10.zip"
Global $iSize = InetGetSize($sUrl) ;siehe Hilfe zu InetgetSize
Global $tStart = TimerInit()
$hDownLoad = InetGet($sUrl, $sPath, 1, 1)
Dim $aData[3]
Do
Sleep(250)
If $aData[0] > 0 Then
_CalcPerformance($aData[0], $aData[2])
TrayTip("downloading", $sMSG, 10, 16)
EndIf
$aData = InetGetInfo($hDownLoad, -1)
Until $aData[2]
$aData = InetGetInfo($hDownLoad, -1)
_CalcPerformance($aData[0], $aData[2])
InetClose($hDownLoad) ; Handle schließen um die Resourcen freizugeben.
MsgBox(0, "", "Bytes gelesen: " & $aData[0] & @CRLF & _
"Größe: " & $aData[1] & @CRLF & _
"beendet?: " & $aData[2] & @CRLF & _
"Erfolgreich?: " & $aData[3] & @CRLF & _
"@error: " & $aData[4] & @CRLF & _
"@extended: " & $aData[5] & @CRLF & @CRLF & _
"KiloBytes/sec: " & $nKBPerSec & @CRLF & _
"benötigte Teit: " & Round($tDiff / 1000, 0) & " Sekunden")
ConsoleWrite("Bytes gelesen: " & $aData[0] & @CRLF & _
"Größe: " & $aData[1] & @CRLF & _
"beendet?: " & $aData[2] & @CRLF & _
"Erfolgreich?: " & $aData[3] & @CRLF & _
"@error: " & $aData[4] & @CRLF & _
"@extended: " & $aData[5] & @CRLF & @CRLF & _
"KiloBytes/sec: " & $nKBPerSec & @CRLF & _
"benötigte Teit: " & Round($tDiff / 1000, 0) & " Sekunden")
;FileDelete(@ScriptDir & "\Testdownload.htm")
[/autoit] [autoit][/autoit] [autoit]Func _CalcPerformance($iRead, $bDone)
[/autoit] [autoit][/autoit] [autoit]$tDiff = TimerDiff($tStart)
$iToDo = Round(($iSize - $iRead) / 1024, 2)
$nKBPerSec = Round($iRead / $tDiff * 1000 / 1024, 2)
$iPercent = Round($iRead / $iSize * 100, 2)
if ($iSize = 0) And Not $bDone Then
$iRTime = "unbekannt"
Else
$iRTime = Round($iToDo / $nKBPerSec, 0)
EndIf
$sMSG = Round($iRead / 1024, 0) & "/" & Round($iSize / 1024, 0) & " KB " & " = " & $iPercent & "%" & @CRLF
$sMSG &= "durchschnittlich KB/s = " & $nKBPerSec & @CRLF ;& "aktuell: KB/s " & $nKBAct & @CRLF
If Not $bDone Then
$sMSG = $sMSG & "vermutlich zu Ende:" & StringLeft(StringRight(_DateAdd('s', $iRTime, _NowCalc()), 8), 5)
;ConsoleWrite($sMSG & @CRLF)
Else
$sMSG = $sMSG & "benötigte Zeit = " & Round($tDiff / 1000, 0)
EndIf
;if $iSize > 0 Then $sMSG = $sMSG & " sec"
EndFunc ;==>_CalcPerformance
mfg autoBert