Jump to content
Sign in to follow this  
Crome_BAD

How to determine download speed

Recommended Posts

Ok, i was messing with the @InetGetActive....and i was wondering how u would determine ur download speed via that....ill post sum code....i tried it....but my actual download speed from the site is 156 KB/Sec....can someone see if this math is right? or if there is a better way to find this?

Func _KeepUpLabel($Program)
    
    While @InetGetActive
        
        $FileSizeOfDownloaded = FileGetSize($Program & ".exe")
        $AmountDone = Round(@InetGetBytesRead / 1048576, 2) & "/" & $Size & " MB Completed"
        $Download_Speed = Round(($FileSizeOfDownloaded - $AmountDone) / 1024, 2)
    ;Sleep(500)  This was to stop "glitching"
        GUICtrlSetData($Label, $AmountDone & "   " & $Download_Speed & " KB/Sec")
        
    WEnd
    
EndFunc

Share this post


Link to post
Share on other sites

Hmm... ($FileSizeOfDownloaded - $AmountDone) - is this speed?..

Anyway, not see need to get actual file size - you already have it in the @InetGetBytesRead macro. Try following code (give right result for me):

$URL = "http://www.autoitscript.com/autoit3/files/beta/autoit/AutoIt3.1.1.43.zip"
GUICreate("GUI")
$Label = GUICtrlCreateLabel("", 5, 5 , 200, 24)
GUISetState()

InetGet ($URL, "AutoIt3.1.1.43.zip", 1, 1)
_KeepUpLabel()

While 1
Wend

Func _KeepUpLabel()
    $timer = TimerInit()
    While @InetGetActive
        $AmountDone = @InetGetBytesRead / 1024; in KB
        $Download_Speed = Round($AmountDone / (TimerDiff($timer) / 1000), 2)
        GUICtrlSetData($Label, Round($AmountDone/1024, 2) & " MB Completed @ " & $Download_Speed & " KB/Sec")
        Sleep(500)
    WEnd
EndFunc

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...