Sign in to follow this  
Followers 0
poisonkiller

Downloading

4 posts in this topic

How can i read how much bytes or mb more until downloading? Example: Im downloading with Autoit one big file. How can i read how many mb or bytes left?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Just get the total size of the file first, then minus the readed bytes:

;$url = your link to the file

;$filename = your place where the file must download to

$size = InetGetSize($url)

InetGet($url, $filename, 0, 1)

While @InetGetActive

$SizeToDownload = $size - @InetGetBytesRead

TrayTip("Download", "Bytes to download: "&$SizeToDownload, 1)

Wend

$SizeToDownload is now how much you still need to download

Edited by Ghastly_MIB

Share this post


Link to post
Share on other sites

This is my code:

#include <GUIConstants.au3>
GUICreate("Autoit download", 200, 100)
        $label = GUICtrlCreateLabel("Write here filename(with "".exe""):", 10, 10, 200, 20)
        $file = GUICtrlCreateInput("", 10, 30, 180, 20)
        $okbutton = GUICtrlCreateButton("Download", 10, 60, 60, 30)
        $read = GUICtrlCreateLabel("Bytes to download: ", 80, 60, 100, 40)
        GUISetState()
        While 1
            $msg = GUIGetMsg()
            If $msg = $okbutton Then
                GUISetState(@SW_DISABLE)
                GUICtrlSetData($label, "Downloading...")
                $size = InetGetSize("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/" &GUICtrlRead($file))
                $inet = InetGet("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/" &GUICtrlRead($file), GUICtrlRead($file))  
                
                While @InetGetActive
                $ToDown = $size - @InetGetBytesRead 
                GUICtrlSetData($read, "Bytes to download: " &$ToDown)
                Wend
                GUICtrlSetData($label, "File downloaded!")
                GUISetState(@SW_ENABLE)
    EndIf
            If $msg = $GUI_EVENT_CLOSE Then ExitLoop
                Wend

Its not setting $ToDown to $read. How can i fix it????

Share this post


Link to post
Share on other sites

Your download is not on the background:

This is the working code:

---------------------------------------------------------------------

#include <GUIConstants.au3>

GUICreate("Autoit download", 200, 100)

$label = GUICtrlCreateLabel("Write here filename(with "".exe""):", 10, 10, 200, 20)

$file = GUICtrlCreateInput("", 10, 30, 180, 20)

$okbutton = GUICtrlCreateButton("Download", 10, 60, 60, 30)

$read = GUICtrlCreateLabel("Bytes to download: ", 80, 60, 100, 40)

GUISetState()

While 1

$msg = GUIGetMsg()

If $msg = $okbutton Then

If GUICtrlRead($file) = "" Then

MsgBox(48, "AutoIt Download", "Please give an place to download to")

Else

GUISetState(@SW_DISABLE)

GUICtrlSetData($label, "Downloading...")

$size = InetGetSize("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe")

$inet = InetGet("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe", GUICtrlRead($file), 0, 1)

While @InetGetActive

$ToDown = $size - @InetGetBytesRead

GUICtrlSetData($read, "Bytes to download: " &$ToDown)

Wend

GUICtrlSetData($label, "File downloaded!")

GUISetState(@SW_ENABLE)

EndIf

EndIf

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Wend

---------------------------------------------------------------------

The line's in red are chanced

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