Sign in to follow this  
Followers 0
slaughter

Download, current DL speed, and downloaded amuont in percent

10 posts in this topic

#1 ·  Posted (edited)

#include <Array.au3>


$avArray = _ArrayCreate( "average" )



$server = "lirknvd-11"; Host from whre

$reklama = "http://"& $server &"/files/8.1.10.50.EXE"; Full link formation
$size = InetGetSize($reklama); Geting size of remote file
Global $i = 0;Varible
Global $new = 0;Varible
Global $speed = 0;Varible
Global $left = 0;Varible
$begin = TimerInit(); Timer start for 1 second determination
$start = TimerInit(); Timer for link speed counting
InetGet($reklama , "version.txt", 1,1); start downloading file to version txt file
While @InetGetActive;;P Read manual noooby;)
$dif = TimerDiff($begin); time difrence
If $dif >= 1000 Then; If difrence hiher tyhen 1 sec

if $i >0 Then
    $rr = TimerDiff($start) /1000/ $i
    $left = (100-$i) * Round($rr,1)
else 
    $left = "Skaicuojama..."; text to output whn speed is counting and no vaible to show
EndIf

$last = $new
$new = @InetGetBytesRead
$speed = Round(($new - $last) /1024)
_ArrayAdd( $avArray,$speed); Add cur speed to array
$begin = TimerInit()
EndIf



$i = round(100 / $size * @InetGetBytesRead)


;displaying
; $i = percent downloaded
; $left = left seconds to complete to download
; $speed = curent link speed
; sp_average($avArray) = Speed average of all download time

TrayTip("Atsiunciamas atnaujinimo failas", " PARSIUSTA: " & $i &  "% Liko: " & $left & " sek Greitis: " & $speed & " kB/s Vidurkis: "& sp_average($avArray) & "kB/s" , 10, 16)
MsgBox(1, "Status", " PARSIUSTA: " & $i &  "% Liko: " & $left & " Greitis: " & $speed & " kB/s Vidurkis: "& sp_average($avArray) & "kB/s", 2)
Sleep(500)
Wend


Func sp_average($arr)
;~  _ArrayDisplay($arr)
    $average = 0
    $count = UBound($arr) -1
    For $r = 1 to UBound($arr,1) - 1
    $average = $average + $arr[$r]
    ConsoleWrite("$average=" & $average & @CRLF)
    ConsoleWrite("$r=" & $r & @CRLF)
    Next
    $averagex = $average / ($r -1)
    ConsoleWrite("$average=" & $averagex & @CRLF)
    Return Round($averagex)
EndFunc

Update:

________Addeded average of speed (thanks Michel Claveau for idea)

Bugs:

________Some how Tray tip does not displays for me?????? Why?

Inprove ideas ect? :)

Edited by slaughter

Share this post


Link to post
Share on other sites



#4 ·  Posted (edited)

Hi!

Easy & efficient. Thanks.

Perhaps, you can separate (add?) average speed & last speed (for cases where speed change during download).

Edited by Michel Claveau

Share this post


Link to post
Share on other sites

Hi!

Easy & efficient. Thanks.

Perhaps, you can separate (add?) average speed & last speed (for cases where speed change during download).

Good idea wonking on it now

Share this post


Link to post
Share on other sites

Hi!

Working ? muttley any comments? :)

Working!

I took your code ; I modified it for my needs, and I use it.

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