Jump to content

Download progress help


Recommended Posts

Hi,

I am making this gui for a couple of programs to update and stuff..

The first progressbar shows the progress for 1 file,

the second progressbar shows progress for total files..

Altough the second progress bar doesn't work..

can you help me??

Func _DownloadGUI($url, $dir, $overwrite = 0)
    $downloadGUI = GUICreate("", 633, 161, -1, -1, $WS_POPUPWINDOW, Default, $Form1)
    $titlebar = GUICtrlCreatePic($barpic, 0, 0, 633, 25)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $bartitle = GUICtrlCreateLabel('Downloading, 0%', 10, 2, @DesktopWidth, 23, Default, $GUI_WS_EX_PARENTDRAG)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetFont(-1, 12, 800, '', 'Arial')
    GUISetBkColor($bkclr)
    $nlmlbl = GUICtrlCreateLabel("Downloading [0/0]:", 8, 40, 150, 17)
    $Progress = GUICtrlCreateProgress(8, 100, 614, 25)
    $Progress2 = GUICtrlCreateProgress(8, 130, 614, 25)
    $staticlabel = GUICtrlCreateLabel("Retreiving files, please wait...", 8, 60, 612, 20)
    GUISetState(@SW_SHOW)
    $retz = ''
    $totalsize = 0
    $donesize = 0
    For $i = 1 to $url[0]
        If StringInStr($url[$i], ' [-PATH-] ') Then
            $zs = StringSplit($url[$i], ' [-PATH-] ', 1)
            $link = $zs[1]
        Else
            $zs = StringSplit($url[$i], ' [-AA-] ', 1)
            $link = $zs[1]
        EndIf
        $totalsize += InetGetSize($link)
    Next
    msgbox(0, $donesize, $totalsize)
    For $i = 1 To $url[0]
        If StringInStr($url[$i], ' [-PATH-] ') Then
            $zs = StringSplit($url[$i], ' [-PATH-] ', 1)
            $fullpath = StringReplace($zs[2], '{TEMPDIR}', @TempDir)
            $link = $zs[1]
            $retz = $fullpath
        Else
            $zs = StringSplit($url[$i], ' [-AA-] ', 1)
            If $zs[0] < 2 Then ExitLoop
            $link = $zs[1]
            $fullpath = $dir & '\' & $zs[2]
        EndIf
        GUICtrlSetData($nlmlbl, "Downloading [" & $i & '/' & $url[0] & ']:')
        GUICtrlSetdata($staticlabel, $fullpath)
        ;ClipPut(ClipGet() & @CRLF & $link & ' - ' & $fullpath)
        $gzz = True
        If $overwrite = 0 Then
            $gzz = False
            If Not FileExists($fullpath) Then $gzz = True
        EndIf
        If $gzz = True Then
            $tSize = InetGetSize($link)
            InetGet($link, $fullpath, 1, 1)
            ;$kb = Round($tSize / 1024)
            If $debug = True Then _DebugWrite('downloading file ' & $i)
            While @InetGetActive
                $P = (100 * @InetGetBytesRead) / $tSize
                $donesize += @InetGetBytesRead
                $P2 = ($donesize/$totalsize)*100
                ;$kbi = Round(@InetGetBytesRead / 1024)
                GUICtrlSetData($Progress, $P)
                GUICtrlSetData($Progress2, $P2)
                GUICtrlSetData($bartitle, 'Downloading, '&Round($P2)&'%')
                Sleep(100)
                Tooltip($donesize&'\'&$totalsize)
            WEnd
            ;If $debug = True Then _DebugWrite('downloaded file ' & $i)
        Else
            $donesize += InetGetSize($link)
        EndIf
        $P2 = ($donesize/$totalsize)*100
        GUICtrlSetData($Progress2, $P2)
        GUICtrlSetData($bartitle, 'Downloading, '&Round($P2)&'%')
    Next
    GUIDelete($downloadGUI)
    Return $retz
EndFunc   ;==>_DownloadGUI
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...