Download lade balken!

  • Hallo Hatte gefragt nach einen Downloader den habe ich freundlicherweiße von "Jautois" bekommen!
    Jetzt habe ich noch eine frage ich habe die txt erstell, hochgeladen usw alles lief ohne probleme nur bei dem Download gibts ein kleines Problem bei 1-100kb dateien geht alles super nur wenn man größere dateien hochladen will zb wie ich 20mb geht der ladebalken auch ganz schnell und die datei ist noch nicht mal anstzweiße fertig geladen! Kennt sich damit einer aus? wie man das mit dem ladebalken regeln kann da das programm ja auch automatisch die größe erkennt! Und als kleines Extra kann man noch einbinden wie schnell man downloaden tut und zb wann es fertig ist das würde ja den downloadbalken entlasen bzw man könnte ihn rausnehmen und dafür die downloadgeschwindigkeit reinschreiben... würde mich auf antwort freuen!

    Das Programm:
    https://autoit.de/index.php?page=Thread&threadID=17911

    MFG

  • Hab mal schnell was gemacht: (mit Beispiel-Downloaddatei)

    [autoit]


    #include <GUIConstantsEx.au3>
    #include <ProgressConstants.au3>
    #include <WindowsConstants.au3>

    [/autoit][autoit][/autoit][autoit]

    $hWindow = GUICreate("Downloadbalken", 402, 42)
    $pProgress = GUICtrlCreateProgress(8, 8, 377, 25)
    $pLabel_Fortschritt = GUICtrlCreateLabel("0 %", 192, 16, 36, 17)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUISetState(@SW_SHOW)

    [/autoit][autoit][/autoit][autoit]

    _Download("http://johannes-log.spacequadrat.de/wordpuzzle/wordpuzzle.swf")

    [/autoit][autoit][/autoit][autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit][autoit][/autoit][autoit]

    EndSwitch
    WEnd

    [/autoit][autoit][/autoit][autoit]

    Func _Download($sFunc_URL = "")
    Local $hDownload = InetGet($sFunc_URL, @ScriptDir & "\wordpuzzle.swf", 1, 1)
    $hDateiGroese = InetGetSize($sFunc_URL)
    Do
    Sleep(100)
    GUICtrlSetData($pProgress,(InetGetInfo($hDownload, 0)/$hDateiGroese)*100)
    GUICtrlSetData($pLabel_Fortschritt,Round((InetGetInfo($hDownload, 0)/$hDateiGroese)*100,1) & " %")
    Until InetGetInfo($hDownload, 2)
    MsgBox(1,"","Download abgeschlossen!")
    GUICtrlSetData($pLabel_Fortschritt,"100 %")
    InetClose($hDownload)
    EndFunc ;==>_Download

    [/autoit]

    Das ganze noch mit einer Speedanzeige:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <ProgressConstants.au3>
    #include <WindowsConstants.au3>
    #include <StaticConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $hWindow = GUICreate("Downloadbalken", 402, 74, 192, 124)
    $pProgress = GUICtrlCreateProgress(8, 8, 377, 25)
    $pLabel_Fortschritt = GUICtrlCreateLabel("0 %", 192, 16, 36, 17)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    $pLabel_Geschw = GUICtrlCreateLabel("0 KB/s", 8, 48, 388, 17, $SS_CENTER)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    _Download("http://johannes-log.de/wordpuzzle/wordpuzzle.swf")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _Download($sFunc_URL = "")
    Local $hDownload = InetGet($sFunc_URL, @ScriptDir & "\wordpuzzle.swf", 1, 1)
    $hDateiGroese = InetGetSize($sFunc_URL)
    $iTimer = TimerInit()
    Do
    Sleep(100)
    GUICtrlSetData($pProgress,(InetGetInfo($hDownload, 0)/$hDateiGroese)*100)
    GUICtrlSetData($pLabel_Fortschritt,Round((InetGetInfo($hDownload, 0)/$hDateiGroese)*100,1) & " %")
    GUICtrlSetData($pLabel_Geschw,Round(InetGetInfo($hDownload, 0)/(TimerDiff($iTimer)),2) & " KB/s")
    Until InetGetInfo($hDownload, 2)
    MsgBox(1,"","Download abgeschlossen!")
    GUICtrlSetData($pLabel_Fortschritt,"100 %")
    InetClose($hDownload)
    EndFunc ;==>_Download

    [/autoit]

    Einmal editiert, zuletzt von Jautois (19. Februar 2010 um 16:11)

  • Du kannst den Code noch optimieren ;) Ersetze dazu folgendes:

    [autoit]

    $hDateiGroese = InetGetSize($sFunc_URL)
    ; MIT:
    Local $hDateiGroese = InetGetInfo($hDownload, 1)

    [/autoit]
  • Dachte ich vorher auch. Allerdings steht in der Funtionsreferenz zu InetGetInfo:

    Deswegen hatte das ganze bei mir nicht funktioniert.

    Sprich $hDateiGroese = InetGetInfo($hDownload, 1) war 0.

  • Dachte ich vorher auch. Allerdings steht in der Funtionsreferenz zu InetGetInfo:


    Deswegen hatte das ganze bei mir nicht funktioniert.

    Sprich $hDateiGroese = InetGetInfo($hDownload, 1) war 0.


    Dann sollte man es so machen, sonst wird auch eine Internetverbindung aufgebaut, wenn es gar nicht nötig ist.

    [autoit]

    Do
    Sleep(10)
    Until InetGetInfo($hDownload, 0) Or InetGetInfo($hDownload, 2) ; warte bis Download anfängt oder fehlerhaft abbricht
    Local $hDateiGroese = InetGetInfo($hDownload, 1)
    If Not $hDateiGroese Then $hDateiGroese = InetGetSize($sFunc_URL)

    [/autoit]
  • Für einen Downloadebalken brauch man doch nichts kompliziertes.
    Ich habe selber mal einen Downloader geschrieben, man muss nur die downgeloadete Größe druch die Dateigröße teilen und mal 100 nehmen und die Progressbar dann nach der Prozentzahl verändern. Hier mein Script zum Downloaden, so klein, dass es eigentlich mehr Beispiel als Script ist.
    Wennd ich etwas falsch verstanden habe sagt es mir.

    Spoiler anzeigen
    [autoit]


    #NoTrayIcon
    #include <GUIConstants.au3>
    #include <WindowsConstants.au3>
    #include <GUIStatusBar.au3>

    [/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Downloader", 509, 164, 193, 125, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_OVERLAPPEDWINDOW,$WS_TILEDWINDOW,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS))
    $Label1 = GUICtrlCreateLabel("URL: ", 16, 16, 36, 17)
    $Input1 = GUICtrlCreateInput("", 72, 16, 321, 21)
    $Label2 = GUICtrlCreateLabel("Downloading: no", 16, 56, 380, 17)
    $Progress1 = GUICtrlCreateProgress(16, 88, 377, 25)
    $Button1 = GUICtrlCreateButton("Download", 416, 32, 81, 25, 0)
    $Button2 = GUICtrlCreateButton("Abort", 416, 80, 81, 25, 0)
    $status=_GUICtrlStatusBar_Create($Form1)
    _GUICtrlStatusBar_SetText($status,"Able to Download: Yes",0,0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    $ding=0
    $h=0
    $x=""
    $ox=""
    global $inet=1

    [/autoit] [autoit][/autoit] [autoit]

    AdlibRegister("adl",10000)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    if $ding=1 Then
    InetClose($h)
    $ding=0
    guictrlsetdata($Progress1,0)
    guictrlsetdata($Label2,"Downloading: Aborted")
    EndIf
    AdlibUnRegister("adl")
    Exit
    case $Button1
    if $ding=0 then
    $xx=1
    $old=0
    $h=0
    $u=guictrlread($Input1)
    $size=Round(InetGetSize($u) / 1024 / 1024,2)
    while $xx<>0
    $xx=stringinstr($u,"/",0,1,$old+1)
    if $xx<>0 then $old=$xx
    WEnd
    $fina=stringmid($u,$old+1)
    $varSaveAs = $fina
    $h=inetget($u,$varSaveAs,0,1)
    $ding=1
    EndIf
    case $Button2
    if $ding=1 Then
    InetClose($h)
    $ding=0
    guictrlsetdata($Progress1,0)
    guictrlsetdata($Label2,"Downloading: Aborted")
    EndIf
    EndSwitch
    if inetgetinfo($h,2)=1 and $ding=1 then
    $ding=0
    guictrlsetdata($Progress1,0)
    guictrlsetdata($Label2,"Downloading: Finished")
    EndIf
    if $ding=1 Then
    $mb=round(inetgetinfo($h,0)/1024/1024,2)
    guictrlsetdata($Label2,"Downloading: "&$mb& " of "&$size&" MB")
    $proz=($mb/$size)*100
    guictrlsetdata($Progress1,$proz)
    EndIf
    $x=guictrlread($Input1)
    if $ox<>$x Then
    $ox=$x
    $si=round(InetGetSize($ox)/1024/1024,2)
    guictrlsetdata($Label2,"Eingabe, Größe: "&$si&" MB")
    EndIf
    sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    func adl()
    if _internetcheck()=0 then
    if $inet=1 then _GUICtrlStatusBar_SetText($status,"Able to Download: No",0,0)
    $inet=0
    Else
    $inet=1
    _GUICtrlStatusBar_SetText($status,"Able to Download: Yes",0,0)
    EndIf
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _internetcheck()
    local $timer = TimerInit()
    While Not Ping("www.google.de")
    Sleep(1000)
    If TimerDiff($timer) > 5000 Then Return 0
    WEnd
    Return 1
    EndFunc

    [/autoit]
  • ja aber was ist das jetzt soll das die modifizierte UpdateGui sein glaube nicht oder?!


    Das ist nur ein Ausschnitt ;) Gesamt sieht das so aus:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <ProgressConstants.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $hWindow = GUICreate("Downloadbalken", 402, 42)
    $pProgress = GUICtrlCreateProgress(8, 8, 377, 25)
    $pLabel_Fortschritt = GUICtrlCreateLabel("0 %", 192, 16, 36, 17)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    If Not _Download("http://johannes-log.spacequadrat.de/wordpuzzle/wordpuzzle.swf") Then
    GUICtrlSetData($pLabel_Fortschritt, "Fehler beim Download")
    EndIf
    ;MsgBox(0, 'Download', "Return: " & _Download("http://johannes-log.spacequadrat.de/wordpuzzle/wordpuzzle.swf") &@CRLF & _
    ; "@error: " & @error & @CRLF & _
    ; "@extended: " & @extended)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _Download($sFunc_URL = "")
    ; Author: Jautois, Prog@ndy
    Local $hDownload = InetGet($sFunc_URL, @ScriptDir & "\wordpuzzle.swf", 1, 1)
    Do
    Sleep(10)
    Until InetGetInfo($hDownload, 0) Or InetGetInfo($hDownload, 2) ; warte bis Download anfängt oder fehlerhaft abbricht
    Local $hDateiGroese = InetGetInfo($hDownload, 1) ; Dateigröße aus InetGet auslesen
    If Not $hDateiGroese And Not InetGetInfo($hDownload,2) Then $hDateiGroese = InetGetSize($sFunc_URL) ; wenn nicht möglich, extra InetGetSize aufrufen
    Do
    Sleep(100)
    GUICtrlSetData($pProgress,(InetGetInfo($hDownload, 0)/$hDateiGroese)*100)
    GUICtrlSetData($pLabel_Fortschritt,Round((InetGetInfo($hDownload, 0)/$hDateiGroese)*100,1) & " %")
    Until InetGetInfo($hDownload, 2)
    MsgBox(1,"","Download abgeschlossen!")
    GUICtrlSetData($pLabel_Fortschritt,"100 %")
    Local $aInfo = InetGetInfo($hDownload)
    InetClose($hDownload)
    Return SetError($aInfo[4], $aInfo[5], $aInfo[3])
    EndFunc ;==>_Download

    [/autoit]

    TheShadowAE: wir waren gerade nur am verbessern des Balkens aus Post #2 ;)