Du musst diesen Teil noch mit in die While-Schleife packen:;
[autoit]$percentage=$progress*100/$size
[/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit]Sonst rechnet er das nie neu aus
Du musst diesen Teil noch mit in die While-Schleife packen:;
[autoit]$percentage=$progress*100/$size
[/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit]Sonst rechnet er das nie neu aus
Hallo HopeFail,
mach es so:
#include <GUIConstants.au3>
[/autoit] [autoit][/autoit] [autoit]Global $download
Global $progress
Global $size
GUICreate("Download", 500, 100)
GUISetState(@SW_SHOW)
$startbutton = GUICtrlCreateButton("Start", 20, 20, 450, 30)
$progressbar = GUICtrlCreateProgress(20, 60, 450, 30)
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $startbutton
$size = InetGetSize("http://www.29soft.com/pc_game_download/download.asp?fid=914")
$download = InetGet("http://www.29soft.com/pc_game_download/download.asp?fid=914", "busdriver_setup-dm.exe", 1, 1)
Do
$progress = InetGetInfo($download, 0)
;$size=InetGetInfo($download,1) ist nicht immer verfügbar siehe Hilfe
$percentage = $progress * 100 / $size
GUICtrlSetData($progressbar, $percentage)
;ConsoleWrite($progress & "/" & $size & @CRLF)
Until InetGetInfo($download, 2)
EndSwitch
WEnd
dein Skript konnte aus verschiedenen Gründen nichts anzeigen
mfg (Ato)Bert
Ich habe mal eine andere Datei genommen und nach deinen Wünschen verändert (hoffe ich):
#include <GUIConstants.au3>
[/autoit] [autoit][/autoit] [autoit]Global $download
Global $percentage
Global $local_size
Global $dl_size
GUICreate("Download",500,100)
GUISetState(@SW_SHOW)
$startbutton=GUICtrlCreateButton("Start",20,10,450,40)
$progressbar=GUICtrlCreateProgress(20,60,450,30)
While 1
$msg = GUIGetMsg()
$download=InetGet("http://www.spieleflut.de/files/download.php?id=56&datei=PVZAtari10973.zip&sec=bf53f601fb0d319c9e2c30ca31f69c17","PVZAtari10973.zip",1,1)
Switch $msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $startbutton
If FileExists(@ScriptDir&"/PVZAtari10973.zip") Then MsgBox(0,"Error","File already exists and is being deleted.")
FileDelete(@ScriptDir&"/PVZAtari10973.zip")
_BarSetProgress($progressbar,$local_size,$dl_size)
Do
$dl_size=InetGetInfo($download,0)
$local_size=InetGetSize("http://www.spieleflut.de/files/download.php?id=56&datei=PVZAtari10973.zip&sec=bf53f601fb0d319c9e2c30ca31f69c17/PVZAtari10973.zip")
Until InetGetInfo($download, 2)
$local_size=InetGetSize("http://www.spieleflut.de/files/download.php?id=56&datei=PVZAtari10973.zip&sec=bf53f601fb0d319c9e2c30ca31f69c17/PVZAtari10973.zip")
EndSwitch
WEnd
Func _BarSetProgress($controlID, $sizeLocal, $sizeDownload)
GUICtrlSetData($controlID,100/$sizeLocal*$sizeDownload)
EndFunc
Das klappt aber auch nicht
Edit: Du hast Hop(e)Fail und (Ato)Bert geschrieben
_BarSetProgress($progressbar,$local_size,$dl_size)
[/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit]das da muss noch in die do-until schleife
Hier nochmal eine Funktion von mir:
;===============================================================================
;
; Description: Downloads a file from the internet in the backround, so the script will be continued a. Also
; sets Progressbar and Speed. Speed must be a label to set.
; Author(s): Burak Kavak
; Syntax: _INet_Download($hDownload, $hTitle[, $vProgress, $vSpeed])
; Parameter(s):
; $hDownload - The URL to download from the internet (required)
; $hTitle - The path where to download the file (with filename) (required)
; $vProgress - The control ID a progressbar if you want to show the progress from the download (default is 0)
; $vSpeed - The control ID of a label where you want to show the KB/s
;
; Return Value(s):
; If the file can't be found - Sets @error to 0
; If the downlaod URL is empty - Sets @error to 1
; If the title - Sets @error to 2
;
;===============================================================================
Func _INet_Download($hDownload, $hTitle, $vProgress = 0, $vSpeed = 0)
If $hDownload = "" Then
SetError(2)
Exit
EndIf
If $hTitle = "" Then
SetError(3)
Exit
EndIf
If $hDownload And $hTitle And $vProgress And $vSpeed <> "" Then
$hGetFile = InetGet($hDownload, $hTitle,1,1)
If $hGetFile = 0 Then
SetError(0)
Exit
EndIf
Sleep(300)
$vTimer = TimerInit()
Do
$hGetProgress = Round((InetGetInfo($hGetFile,0)/InetGetSize($hDownload, 1))*100,0)
GUICtrlSetData($vProgress, $hGetProgress)
$hGetSpeed = Round(InetGetInfo($hGetFile, 0)/TimerDiff($vTimer), 0)
GUICtrlSetData($vSpeed, $hGetSpeed & " KB/s")
Sleep(200)
Until InetGetInfo($hGetFile, 2)
GUICtrlSetData($vProgress, "100")
EndIf
If $vProgress And $vSpeed = 0 And $hDownload And $hTitle <> "" Then
$hGetFile = InetGet($hDownload, $hTitle,1,1)
If $hGetFile = 0 Then
SetError(0)
Exit
EndIf
Do
Sleep(200)
Until InetGetInfo($hGetFile, 2)
EndIf
If $vProgress = 0 And $hDownload And $hTitle And $vSpeed <> "" Then
$hGetFile = InetGet($hDownload, $hTitle,1,1)
If $hGetFile = 0 Then
SetError(0)
Exit
EndIf
Sleep(250)
$vTimer = TimerInit()
Do
$hGetSpeed = Round(InetGetInfo($hGetFile, 0)/TimerDiff($vTimer), 0)
GUICtrlSetData($vSpeed, $hGetSpeed & " KB/s")
Sleep(200)
Until InetGetInfo($hGetFile, 2)
EndIf
If $vSpeed = 0 And $hDownload And $hTitle And $vProgress <> "" Then
$hGetFile = InetGet($hDownload, $hTitle,1,1)
If $hGetFile = 0 Then
SetError(0)
Exit
EndIf
Sleep(300)
Do
$hGetProgress = Round((InetGetInfo($hGetFile,0)/InetGetSize($hDownload, 1))*100,0)
GUICtrlSetData($vProgress, $hGetProgress)
Sleep(200)
Until InetGetInfo($hGetFile, 2)
GUICtrlSetData($vProgress, "100")
EndIf
EndFunc
Braucht keine anderen Includes...
edit://
example:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Download", 170, 110, 192, 124)
$Progress1 = GUICtrlCreateProgress(8, 8, 150, 17)
$Label1 = GUICtrlCreateLabel("Speed", 64, 32, 35, 37)
$Button1 = GUICtrlCreateButton("Download", 8, 76, 155, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_INet_Download("http://download.thinkbroadband.com/10MB.zip",@DesktopDir & "\_inet_download_test.zip",$Progress1,$Label1)
MsgBox(0,"","Success!")
EndSwitch
WEnd
;===============================================================================
;
; Description: Downloads a file from the internet in the backround, so the script will be continued a. Also
; sets Progressbar and Speed. Speed must be a label to set.
; Author(s): Burak Kavak
; Syntax: _INet_Download($hDownload, $hTitle[, $vProgress, $vSpeed])
; Parameter(s):
; $hDownload - The URL to download from the internet (required)
; $hTitle - The path where to download the file (with filename) (required)
; $vProgress - The control ID a progressbar if you want to show the progress from the download (default is 0)
; $vSpeed - The control ID of a label where you want to show the KB/s
;
; Return Value(s):
; If the file can't be found - Sets @error to 0
; If the downlaod URL is empty - Sets @error to 1
; If the title - Sets @error to 2
;
;===============================================================================
Func _INet_Download($hDownload, $hTitle, $vProgress = 0, $vSpeed = 0)
If $hDownload = "" Then
SetError(2)
Exit
EndIf
If $hTitle = "" Then
SetError(3)
Exit
EndIf
If $hDownload And $hTitle And $vProgress And $vSpeed <> "" Then
$hGetFile = InetGet($hDownload, $hTitle,1,1)
If $hGetFile = 0 Then
SetError(0)
Exit
EndIf
Sleep(300)
$vTimer = TimerInit()
Do
$hGetProgress = Round((InetGetInfo($hGetFile,0)/InetGetSize($hDownload, 1))*100,0)
GUICtrlSetData($vProgress, $hGetProgress)
$hGetSpeed = Round(InetGetInfo($hGetFile, 0)/TimerDiff($vTimer), 0)
GUICtrlSetData($vSpeed, $hGetSpeed & " KB/s")
Sleep(200)
Until InetGetInfo($hGetFile, 2)
GUICtrlSetData($vProgress, "100")
EndIf
If $vProgress And $vSpeed = 0 And $hDownload And $hTitle <> "" Then
$hGetFile = InetGet($hDownload, $hTitle,1,1)
If $hGetFile = 0 Then
SetError(0)
Exit
EndIf
Do
Sleep(200)
Until InetGetInfo($hGetFile, 2)
EndIf
If $vProgress = 0 And $hDownload And $hTitle And $vSpeed <> "" Then
$hGetFile = InetGet($hDownload, $hTitle,1,1)
If $hGetFile = 0 Then
SetError(0)
Exit
EndIf
Sleep(250)
$vTimer = TimerInit()
Do
$hGetSpeed = Round(InetGetInfo($hGetFile, 0)/TimerDiff($vTimer), 0)
GUICtrlSetData($vSpeed, $hGetSpeed & " KB/s")
Sleep(200)
Until InetGetInfo($hGetFile, 2)
EndIf
If $vSpeed = 0 And $hDownload And $hTitle And $vProgress <> "" Then
$hGetFile = InetGet($hDownload, $hTitle,1,1)
If $hGetFile = 0 Then
SetError(0)
Exit
EndIf
Sleep(300)
Do
$hGetProgress = Round((InetGetInfo($hGetFile,0)/InetGetSize($hDownload, 1))*100,0)
GUICtrlSetData($vProgress, $hGetProgress)
Sleep(200)
Until InetGetInfo($hGetFile, 2)
GUICtrlSetData($vProgress, "100")
EndIf
EndFunc