Sign in to follow this  
Followers 0
Synapse

Steam lookalike file downloader

4 posts in this topic

#1 ·  Posted (edited)

Here is the script i`ve made...it works very well if u have a good and fast internet connection...if not or the file u wanna download is on a slow server the script is going crazy...it shows some strange numbers instead of the %, remaining time or download speed...so if anyone can figure it out y or how to solve this please post <_< THX...

Posted Image

In the screenshot i`m downloading the latest ubuntu linux...cuz the server is great the script runs without problems...

KNOWN PROBLEMS:

* shows strange numbers if the script can`t calculate the size of the file

TO DO:

* before the download starts it should ask for the path were the file will pe put (default 4 now is @DesktopDir)

* show in title the name of the downloaded file + the % done

#NoTrayIcon
#Include <string.au3>
#include <GUIConstants.au3>
ProcessSetPriority("AutoIt3.exe", 0)
Dim $url="http://ftp.iasi.roedu.net/mirrors/ubuntulinux.org/releases/gutsy/ubuntu-7.10-desktop-i386.iso"
$FileName = StringRight($url,StringLen($url) - StringInStr($url,"/",0,-1))
Global $width = 400
Global $height = 200
Global $flag = 0
$Form1 = GUICreate("Download", $width, $height, -1, -1, $WS_POPUP)
        GUISetBkColor(0x464646)
        $Close= GUICtrlCreateLabel("x", $width - 15, 3, 11, 20)
        GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        GUICtrlSetCursor (-1, 0)
        $Minimize= GUICtrlCreateLabel("_", $width - 30, 1, 11, 20)
        GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        GUICtrlSetCursor (-1, 0)
        $Title= GUICtrlCreateLabel("Download - "& $FileName, 10, 6, 1100, 20, -1 ,$GUI_WS_EX_PARENTDRAG)
        GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $Graphic1 = GUICtrlCreateGraphic(0, 0, 1000, 25)
        GUICtrlSetBkColor(-1, 0x5A6A50)
        $DonwloadTitle= GUICtrlCreateLabel("Downloading "& $FileName, 20, 60, 400, 50)
        GUICtrlSetFont(-1, 10, 800, 0, "Verdana") 
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $progressBar = GUICtrlCreateProgress(20, 100, $width-45, 25, $PBS_SMOOTH)
        GUICtrlSetColor(-1, 0x5A6A50)   
        GUICtrlSetBkColor(-1, 0x464646)
        $downloadedSoFarInput = GUICtrlCreateLabel("0", 20, 135, 40, 10, $SS_RIGHT)
        GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $downloadedSoFar = GUICtrlCreateLabel("MB done", 65, 135, 250)
        GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        $slash = GUICtrlCreateLabel("/", 120, 135, 250)
        GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $lefToDownloadInput = GUICtrlCreateLabel("???", 130, 135,40, 17, $SS_RIGHT)
        GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $leftToDownload = GUICtrlCreateLabel("MB left", 175, 135, 250)
        GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $timeRemainingInput = GUICtrlCreateLabel("???", $width - 45, $height - 20, 55, 17, $ES_LEFT)
        GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $timeRemaining = GUICtrlCreateLabel("Minutes left:", $width - 120, $height - 20, 250)
        GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $At = GUICtrlCreateLabel("@", 20 , $height - 20, 55, 17, $ES_LEFT)
        GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $KBpsInput = GUICtrlCreateLabel("???", 35 , $height - 20, 55, 17, $ES_LEFT)
        GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $KBps = GUICtrlCreateLabel("KB/s", 80, $height - 20, 250)
        GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $percentElapsedInput = GUICtrlCreateLabel("0.00", $width/2 - 10, 106, 55, 17)
        GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0x000000)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $percent = GUICtrlCreateLabel("%", $width/2 + 21, 106, 55, 17)
        GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0x000000)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUISetState(@SW_SHOW)
_GuiRoundCorners($Form1, 0, 0, 5, 5);<= Patent GUI Glass style
        Call("download")
        While 1
            If NOT WinActive("Download", "Download") Then
                WinSetTrans ( "Download", "Download", 220 )
                $flag = 0
            Else
                If $flag = 0 Then
                    WinSetTrans ( "Download", "Download", 255 )
                    $flag = 1
                EndIf
            EndIf
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $Close
                    InetGet("abort")
                    Exit
                Case $Minimize
                    GUISetState(@SW_MINIMIZE,$Form1)
            EndSwitch
        WEnd
Func download()
;~  Global $url = "http://ftp.iasi.roedu.net/mirrors/ubuntulinux.org/releases/gutsy/ubuntu-7.10-desktop-i386.iso"
   Global $fileSize = InetGetSize($url)
   Sleep(1000)
   Global $startDownloadTime = TimerInit()
   InetGet($url, @DesktopDir & "\" & StringRight($url, StringInStr(_StringReverse($url), "/") - 1), 0, 1)
   AdlibEnable("progress", 1000)
EndFunc;==>download
Func progress()
   If @InetGetActive Then
      GUICtrlSetData($KBpsInput, StringFormat("%.3f", (@InetGetBytesRead / 1024) / ( (TimerDiff($startDownloadTime) / 1000))))
      GUICtrlSetData($downloadedSoFarInput, StringFormat("%.2f", (@InetGetBytesRead / 1024) / 1024))
      GUICtrlSetData($lefToDownloadInput, StringFormat("%.2f", ($fileSize / 1024) - (@InetGetBytesRead / 1024) / 1024))
;~     GUICtrlSetData($timeElapsedInput, StringFormat("%.2f", 60 - (3600000 - TimerDiff($startDownloadTime)) / 60000))
      GUICtrlSetData($timeRemainingInput, StringFormat("%.2f", 60 - (3600000 - ( ($fileSize - @InetGetBytesRead) / @InetGetBytesRead) * TimerDiff($startDownloadTime)) / 60000))
      GUICtrlSetData($percentElapsedInput, StringFormat("%.2f", (@InetGetBytesRead / $fileSize) * 100))
;~     GUICtrlSetData($percentRemainingInput, StringFormat("%.2f", (100 - (@InetGetBytesRead / $fileSize) * 100)))
      GUICtrlSetData($progressBar, (@InetGetBytesRead / $fileSize) * 100)
   EndIf
   If @InetGetActive = 0 Then
       WinSetTrans ( "Download", "Download", 130 )
       GUISetState(@SW_DISABLE,$Form1)
       $Form2 = GUICreate("Download complete", $width, $height, -1, -1, $WS_POPUP)
        GUISetBkColor(0x464646)
;~ $Close2= GUICtrlCreateLabel("x", $width - 15, 3, 11, 20)
        GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
;~ $Minimize2= GUICtrlCreateLabel("_", $width - 30, 1, 11, 20)
        GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $Title2= GUICtrlCreateLabel("Download Complete", 10, 6, 1100, 20)
        GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $Graphic1 = GUICtrlCreateGraphic(0, 0, 1000, 25)
        GUICtrlSetBkColor(-1, 0x5A6A50)
        $Label1 = GUICtrlCreateLabel("Download Succesful", 100, 70, 300, 17)
        GUICtrlSetFont(-1, 13, 800, 0, "Verdana")
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        $Button1 = GUICtrlCreateButton("Finish", $width / 2 - 37, 130, 75, 25, 0)
        GUICtrlSetFont(-1, 8, 800, 0, "Verdana")
        GUICtrlSetBkColor(-1, 0x555852)
        GUICtrlSetColor(-1, 0xFFFFFF)
        GUICtrlSetCursor (-1, 0)
        GUISetState(@SW_SHOW)
        _GuiRoundCorners($Form2, 0, 0, 5, 5);<= Patent GUI Glass style
        WinSetOnTop ( "Download", "Download", 1 )
        While 1
            $nMsg = GUIGetMsg()
            Switch $nMsg
                Case $Button1
                    Exit
            EndSwitch
        WEnd
      AdlibDisable()
   EndIf
EndFunc;==>progress
Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3);==>_GuiRoundCorners
   Dim $pos, $ret, $ret2
   $pos = WinGetPos($h_win)
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long",  $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3,  "long", $i_y3)
   If $ret[0] Then
      $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
      If $ret2[0] Then
         Return 1
      Else
         Return 0
      EndIf
   Else
      Return 0
   EndIf
EndFunc;==>_GuiRoundCorners

Downloader Updated by Alien13 :)

-added select the download link input

-added save name and save location

Download

Edited by Synapse

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0