File Downloader v1.0

  • Hey, habe mal wieder ein kleines Script geschrieben.
    Es ist ganz Simpel, an wählt sich eine URL aus, von wo man Downloaden möchte, man gibt den Speicherpfad ein, und mein Tool downloaded.
    Ich habe die Progressbar nicht der tatsächlichen Dateigröße angepasst, sondern die Progressbar wird einfach immer größer, aber es ist auch nur ein kleines Script und kein Projekt
    Viel Spass!

  • Hi pridrage

    sieht schon ganz nett aus
    aber ich würde die progressbar der dateigröße anpassen und auch mal aufwendigere Scripte schreiben :thumbup:

    gruss Simon

  • 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)

    [autoit]

    #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

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

    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

    [/autoit]

    Einmal editiert, zuletzt von andygo (14. November 2009 um 17:58)