paar handgriffe und schon zeigt der prozentbalken den echten fortschritt an
und der download kann auch abgebrochen werden.
(ACHTUNG: code ist für autoit 3.3.1.5 beta, neue inetget)
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("File Downloader v1.0", 349, 238, 192, 124)
$Input1 = GUICtrlCreateInput("", 24, 48, 289, 21)
$Button1 = GUICtrlCreateButton("Download", 96, 88, 121, 73, $WS_GROUP)
$Progress1 = GUICtrlCreateProgress(24, 184, 289, 25)
$label = GUICtrlCreatelabel("", 24, 210, 289, 20, $SS_CENTER )
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_FileDownload()
EndSwitch
WEnd
Func _FileDownload()
Local $url, $FSDUrl
$url = GUICtrlRead($Input1)
$size = InetGetSize($url)
$FSDUrl = FileSaveDialog("Speichern", @DesktopDir, "Alle Dateien(*.*)")
$update = InetGet($url, $FSDUrl, 1, 1)
$toshow=TimerInit()
local $sofar
sleep(2000)
GUICtrlSetData($button1,"Cancel")
do
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button1
GUICtrlSetData($button1,"Download")
EndSwitch
if TimerDiff($toshow)>100 Then
$sofar=InetGetInfo($update, 0)
GUICtrlSetData($Progress1, int(($sofar/$size)*100))
GUICtrlSetData($label ,int($sofar/1024) & " kb von " & int($size/1024) & " kb")
$toshow=TimerInit()
endif
if InetGetInfo($update, 2) then GUICtrlSetData($button1,"Download")
until GUICtrlRead ($button1) = "Download"
GUICtrlSetData($Progress1, 0)
GUICtrlSetData($label ,"")
$cancel = 0
if InetGetInfo($update, 2) and InetGetInfo($update, 3) then
InetClose($update)
MsgBox(64,"Info","Download erfolgreich.")
Else
InetClose($update)
msgbox (16,"Info","Download fehlgeschlagen!")
endif
GUICtrlSetData($button1,"Download")
EndFunc