Sign in to follow this  
Followers 0
D4rk^S0ul

Downloader

2 posts in this topic

Atm i am tryin to make a downloader program but i cant seem to get the progress bar to work it goes straight from like 1% to 100% before the file has downloaded the code i have so far is:

#include <GuiConstants.au3>

GuiCreate("Speed-Loader v1", 335, 119,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Progress_1 = GuiCtrlCreateProgress(20, 80, 290, 20)
$Input_2 = GuiCtrlCreateInput("", 20, 20, 200, 20)
$Button_3 = GuiCtrlCreateButton("Download", 230, 20, 80, 20)
$Input_4 = GuiCtrlCreateInput("C:\", 20, 50, 290, 20)

GuiSetState()

While 1
    Dim $Size = 0, $FileSize = 0, $CurrentSize = 0, $Percent = 0
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_3
        If GUICtrlRead($Input_2) = "" Then
            MsgBox(0, "File", "Please enter a file to download!")
        Else
            If InetGetSize(GUICtrlRead($Input_2)) = 0 Then
                MsgBox(16, "Error", "No such file exists at that url!")
            Else
                $Size = InetGetSize(GUICtrlRead($Input_2))
                InetGet(GUICtrlRead($Input_2), GUICtrlRead($Input_4), 1, 1)
                While 1
                    $FileSize = FileGetSize(GUICtrlRead($Input_4))
                    If $FileSize = $Size Then
                        MsgBox(0, "Complete", "Download is Complete!")
                        ExitLoop
                    Else
                        $CurrentSize = $Size / $FileSize
                        $Percent = $CurrentSize * 100
                        GUICtrlSetData($Progress_1, $Percent)
                        $CurrentSize = 0
                        $Percent = 0
                    EndIf
                WEnd
            EndIf
        EndIf
    EndSelect
WEnd
Exit

Share this post


Link to post
Share on other sites



I relised my stupid mistake now i put the wrong definations on different sides when dividing :o

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