Jump to content

Downloading


Recommended Posts

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
Link to comment
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????

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...