Hallo com,
hier einmal ein kleines Beispiel wie man mehrere Downloads nacheinander machen kann und dabei in einer Progressbar den Fortschritt des Downloads der aktuellen Datei und in einer 2. den Gesamt-Fortschritt anzeigen lassen kann.
Spoiler anzeigen
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <Array.au3>
Opt('MustDeclareVars', 1)
[/autoit] [autoit][/autoit] [autoit]Local $sLocalPath = @ScriptDir & "\Test"
If Not FileExists($sLocalPath) Then DirCreate($sLocalPath)
Local $aFiles[5][4] ;zeile 0 für Gesamtgrösse Spalten 0=URL, 1=Lokaler Pfad, 2=DL-Grösse,3=erfolgreich
Local $aData[1]
$aFiles[0][0] = 4 ;Anzahl der Downloads
$aFiles[0][1] = 0 ;wird im Skript für Bytes der getätigten Donwloads verwendet
$aFiles[1][0] = "http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe"
$aFiles[1][1] = $sLocalPath & "\autoit-v3-setup.exe"
$aFiles[2][0] = "http://www.autoitscript.com/autoit3/files/beta/autoit/autoit-v3.3.5.6-beta-setup.exe"
$aFiles[2][1] = $sLocalPath & "\autoit-v3.3.5.6-beta-setup.exe"
$aFiles[3][0] = "http://translation.autoit.de/autoitinfo/hilfedateien/AutoIt-Hilfe-Deutsch-3.3.6.1-Stand-07_09_10.zip"
$aFiles[3][1] = $sLocalPath & "\AutoIt-Hilfe-Deutsch-3.3.6.1-Stand-07_09_10.zip"
$aFiles[4][0] = "http://www.autoitscript.com/forum/index.php?app=core&module=attach§ion=attach&attach_app=core&module=attach§ion=attach&attach_id=29947"
$aFiles[4][1] = $sLocalPath & "\OrganizeInclides.zip"
Local $wait, $s, $msg, $m, $hDL, $iPercent, $iPercentAll
[/autoit] [autoit][/autoit] [autoit]Local $hGuiMain = GUICreate("Download-Beispiel", 220, 100, 100, 200)
[/autoit] [autoit][/autoit] [autoit]DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 0) ; Classic-Style
Local $progressbar1 = GUICtrlCreateProgress(10, 10, 200, 20)
GUICtrlSetColor(-1, 32250); not working with Windows XP Style
DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 7) ; Standard-Windows-Style
Local $hGuiChild1 = GUICreate("LABELGUI", 200, 20, 10, 10, $WS_POPUP, $WS_EX_MDICHILD, $hGuiMain)
Local $Label1 = GUICtrlCreateLabel("", 10, 0, 200, 20, $SS_CENTER)
GUICtrlSetFont(-1, 12, 1400)
WinSetTrans($hGuiChild1, "", 180)
GUISwitch($hGuiMain)
Local $progressbar2 = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH)
Local $button = GUICtrlCreateButton("Start", 75, 70, 70, 20)
Local $hGuiChild2 = GUICreate("LABELGUI", 200, 20, 10, 40, $WS_POPUP, $WS_EX_MDICHILD, $hGuiMain)
Local $Label2 = GUICtrlCreateLabel("", 10, 0, 200, 20, $SS_CENTER)
GUICtrlSetFont(-1, 12, 1400)
WinSetTrans($hGuiChild2, "", 180)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetBkColor(-1, -2)
GUISetState(@SW_SHOW, $hGuiMain)
GUISetState(@SW_SHOW, $hGuiChild1)
GUISetState(@SW_SHOW, $hGuiChild2)
WinActivate($hGuiMain)
Do
$msg = GUIGetMsg()
Switch $msg
Case $button
GUICtrlSetState($button, $GUI_DISABLE)
WinActivate($hGuiMain)
For $i = 1 To $aFiles[0][0]
$aFiles[$i][2] = InetGetSize($aFiles[$i][0]) ;Downloadgrösse ermitteln
$aFiles[0][2] += $aFiles[$i][2] ;und auch zur Gesamtdownloadgrösse hinzuzählen
Next
;_ArrayDisplay($aFiles)
For $i = 1 To $aFiles[0][0]
$hDL = InetGet($aFiles[$i][0], $aFiles[$i][1], 1, 1)
$aData[0] = 0
Do
Sleep(250)
$aData = InetGetInfo($hDL, -1)
If $aData[0] > 0 Then
$iPercent = Round($aData[0] / $aFiles[$i][2] * 100, 2)
$aFiles[$i][3] = $iPercent
$iPercentAll = Round(($aData[0] + $aFiles[0][1]) / $aFiles[0][2] * 100, 2)
If GUICtrlRead($Label1) <> $iPercent Then
GUICtrlSetData($progressbar1, $iPercent)
GUICtrlSetData($Label1, $iPercent & " % Datei " & $i)
EndIf
If GUICtrlRead($Label2) <> $iPercentAll Then
GUICtrlSetData($progressbar2, $iPercentAll)
GUICtrlSetData($Label2, $iPercentAll & " % Gesamt")
EndIf
ConsoleWrite($i & ". File : " & $iPercent & " " & $iPercentAll & " " & $aFiles[0][1] & @CRLF) ;zu Debg-Zwecken kann auskommentiert werden
If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
EndIf
Until $aData[2]
InetClose($hDL)
$aFiles[0][1] += $aFiles[$i][2] ;gerade abgeschlossenen Download zu bereits heruntergeladen addieren
If $aData[3] Then $aFiles[$i][3] = "100 %"
Next
$aFiles[0][0] = "URL"
$aFiles[0][1] = "Lokaler Pfad"
$aFiles[0][2] = "Grösse"
$aFiles[0][3] = "Erfolg"
_ArrayDisplay($aFiles, "Downloadergebnisse")
Exit
EndSwitch
Until $msg = $GUI_EVENT_CLOSE
Edit: Skript ausgetauscht
mfg autoBert