Downloader umschreiben

  • Hallo
    ich habe eine au3 gesehn das ein downloader hat und den habe ich rausgeschnibbelt aber ich krige das nicht in mein syples script gestopft :(

    könnte es jemand so zurecht rücken das es auch geht pls

    Spoiler anzeigen
    [autoit]

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

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 436, 99, 192, 124)
    $Input1 = GUICtrlCreateInput("", 0, 0, 433, 21)
    $Progress1 = GUICtrlCreateProgress(0, 24, 430, 17)
    $Label1 = GUICtrlCreateLabel("", 0, 48, 428, 17)
    $Button1 = GUICtrlCreateButton("ok", 8, 72, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("exit", 120, 72, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    GUICtrlSetData($Label1,"... wird heruntergeladen")
    $SSAVEFILEPATH = FileSelectFolder("Speichern unter ... ", @DesktopDir, 7, @DesktopDir)
    If @error = 1 Then
    Else
    InetGet($SFILEPATHONSERVER & $SNAMESELECTEDFILE, $SSAVEFILEPATH & "\" & $SNAMESELECTEDFILE, 1, 1)
    While @InetGetActive
    GUICtrlSetData($Progress1, (@InetGetBytesRead / $IDATAFILESIZE[$ITEMPINDEX[1] + 1] / 10))
    GUICtrlSetData($PLABELINFO, "Download: " & $SNAMESELECTEDFILE & " - " & Int(@InetGetBytesRead / 1000) & "/" & $IDATAFILESIZE[$ITEMPINDEX[1] + 1] & " KB - " & Int((@InetGetBytesRead / $IDATAFILESIZE[$ITEMPINDEX[1] + 1] / 10)) & " %")
    Sleep(100)
    WEnd
    GUICtrlSetData($Progress1, 100)
    GUICtrlSetData($Label1, "Fertig geladen!")
    Sleep(1000)
    EndIf
    Case $Button2
    Exit
    EndSwitch
    WEnd

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

    in den input kommt die url rein zu der datei
    mehr braucht man ja nicht sagen ^^

    • Offizieller Beitrag
    Spoiler anzeigen
    [autoit]

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

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 436, 99, 192, 124)
    $Input1 = GUICtrlCreateInput("", 0, 0, 433, 21)
    $Progress1 = GUICtrlCreateProgress(0, 24, 430, 17)
    $Label1 = GUICtrlCreateLabel("", 0, 48, 428, 17)
    $Button1 = GUICtrlCreateButton("ok", 8, 72, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("exit", 120, 72, 75, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    GUICtrlSetData($Label1, "... wird heruntergeladen")
    ;~ $SSAVEFILEPATH = FileSelectFolder("Speichern unter ... ", @DesktopDir, 7, @DesktopDir)
    If @error <> 1 Then
    ;~ Local $hDownload = InetGet($SFILEPATHONSERVER & $SNAMESELECTEDFILE, $SSAVEFILEPATH & "\" & $SNAMESELECTEDFILE, 1, 1)
    Local $hDownload = InetGet("http://dl.cdn.chip.de/downloads/26793/gimp-2.6.6-i686-setup.exe?1246448001-1246455501-d4540a-B-b00780cabf1651fa109345f45586d189.exe", @DesktopDir & '\gimp-2.6.6-i686-setup.exe' , 1, 1)
    Local $nBytes = InetGetInfo($hDownload, 1)
    Do
    GUICtrlSetData($Progress1, InetGetInfo($hDownload, 0) * 100 / $nBytes)
    ConsoleWrite(InetGetInfo($hDownload, 0) * 100 / $nBytes & @CRLF)
    GUICtrlSetData($Label1, "Download: " & InetGetInfo($hDownload, 0) & " von " & InetGetInfo($hDownload, 1))
    Sleep(500)
    Until InetGetInfo($hDownload, 2) ; Check if the download is complete.

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

    InetClose($hDownload) ; Close the handle to release resourcs.

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

    GUICtrlSetData($Progress1, 100)
    GUICtrlSetData($Label1, "Fertig geladen!")
    Sleep(1000)
    EndIf
    Case $Button2
    Exit
    EndSwitch
    WEnd

    [/autoit]