Sign in to follow this  
Followers 0
antiviruscoder

progress bar

13 posts in this topic

The problem that im haveing is, I need the gui to stay as it is because im going to add quite a few more buttens soon. The only problem with it is, the progress bar doesnt move during the download process. could anyone help?

heres the code

#include <GUIConstants.au3>

GuiCreate("OPENGEN DOWNLOAD CENTER", 750, 350,(@DesktopWidth-157)/3, (@DesktopHeight-300)/3)
$progressbar1 = GUICtrlCreateProgress (20,300,700,40)
GUICtrlSetColor(-1,32250); not working with Windows XP Style

$FileUrl = "http://www.virustester.knight47.com/newistantivirustest.zip"
$FileSize = InetGetSize($FileUrl)
$FileName = StringSplit($FileUrl, "/")
$FileName = $FileName[$FileName[0]]

$button1 = GUICtrlCreateButton("download", 20, 20, 100, 50) 

GuiSetState() 
While 1 
    $msg = GuiGetMsg() 
    Select 
    Case $msg = $GUI_EVENT_CLOSE 
        ExitLoop 
; Executer 
   Case $msg = $button1 
Sleep(500); display for 5 seconds.
InetGet($FileUrl,@scriptdir & "\" & $FileName, 1, 1)
TrayTip("", "download in progress... Please don't shutdown or restart your computer for any reason!!!", 5)
HotKeySet("{ESC}", "_InetGetAbort")


While @InetGetActive
    $Progressbar1 = Int((100 * @InetGetBytesRead) / $FileSize)
    
    Sleep(250)
WEnd

Func _InetGetAbort()
    InetGet("abort")
EndFunc;==> _InetGetAbort()
EndSelect 
WEnd 
Exit

thx very much


[center][spoiler]My little joke!!!![/spoiler][/center][center]!!!!!!!!!!!!!!!!!!!!!!!!!!!!![/center][center]Best code site ever[/center][center]!!!!!!!!!!!!!!!!!!!!!!!!!!!!![/center][center][spoiler]My litte joke!!!![/spoiler][/center]

Share this post


Link to post
Share on other sites



Run au3check from SciTe editor and you'll see some of your errors, get those cleaned up (one I spot right away is you can't have a function within a loop like that)... anyway, fix the errors it says you have, and if it still doesn't work, post the syntaxed corrected code for more help.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Ok i ran it and i cant understand what it says... this is what it gave me:

>C:\Program Files\AutoIt3\SciTE\..\au3check.exe "C:\Users\draygoes\Desktop\download.au3"
AutoIt3 Syntax Checker v1.54  Copyright (c) Tylo 2006

C:\Users\draygoes\Desktop\download.au3(34,1) : ERROR: missing EndSelect.
Func
^
C:\Users\draygoes\Desktop\download.au3(17,12) : REF: missing EndSelect.
    Select 
~~~~~~~~~~~^
C:\Users\draygoes\Desktop\download.au3(34,1) : ERROR: missing Wend.
Func
^
C:\Users\draygoes\Desktop\download.au3(15,1) : REF: missing Wend.
While
^
C:\Users\draygoes\Desktop\download.au3(37,1) : ERROR: syntax error
EndSelect
^
C:\Users\draygoes\Desktop\download.au3 - 3 error(s), 0 warning(s)
>Exit code: 2   Time: 0.618

[center][spoiler]My little joke!!!![/spoiler][/center][center]!!!!!!!!!!!!!!!!!!!!!!!!!!!!![/center][center]Best code site ever[/center][center]!!!!!!!!!!!!!!!!!!!!!!!!!!!!![/center][center][spoiler]My litte joke!!!![/spoiler][/center]

Share this post


Link to post
Share on other sites

I took a stab in the dark here

#include <GUIConstants.au3>

GuiCreate("OPENGEN DOWNLOAD CENTER", 750, 350,(@DesktopWidth-157)/3, (@DesktopHeight-300)/3)
$progressbar1 = GUICtrlCreateProgress (20,300,700,40)
GUICtrlSetColor(-1,32250); not working with Windows XP Style

$FileUrl = "http://www.virustester.knight47.com/newistantivirustest.zip"
$FileSize = InetGetSize($FileUrl)
$FileName = StringSplit($FileUrl, "/")
$FileName = $FileName[$FileName[0]]

$button1 = GUICtrlCreateButton("Download", 20, 20, 100, 50)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    ; Executer
    Case $msg = $button1
        InetGet($FileUrl,@scriptdir & "\" & $FileName, 1, 1)
        While @InetGetActive
            GUICtrlSetData($Progressbar1,(@InetGetBytesRead / $FileSize)*100)
            Sleep(250)
            TrayTip("Progress: "&(@InetGetBytesRead / $FileSize)*100, "Download in progress... Please don't shutdown or restart your computer for any reason!!!", 5)
            HotKeySet("{ESC}", "_InetGetAbort")
        WEnd
        GUICtrlSetData($Progressbar1,100)
        TrayTip("","Download Complete. Downloader will now close.",5)
        Sleep(5000)
        Exit
    EndSelect
WEnd



Func _InetGetAbort()
    InetGet("abort")
EndFunc;==> _InetGetAbort()
Exit

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Ok i ran it and i cant understand what it says... this is what it gave me:

>C:\Program Files\AutoIt3\SciTE\..\au3check.exe "C:\Users\draygoes\Desktop\download.au3"
AutoIt3 Syntax Checker v1.54  Copyright (c) Tylo 2006

C:\Users\draygoes\Desktop\download.au3(34,1) : ERROR: missing EndSelect.
Func
^
C:\Users\draygoes\Desktop\download.au3(17,12) : REF: missing EndSelect.
    Select 
~~~~~~~~~~~^
C:\Users\draygoes\Desktop\download.au3(34,1) : ERROR: missing Wend.
Func
^
C:\Users\draygoes\Desktop\download.au3(15,1) : REF: missing Wend.
While
^
C:\Users\draygoes\Desktop\download.au3(37,1) : ERROR: syntax error
EndSelect
^
C:\Users\draygoes\Desktop\download.au3 - 3 error(s), 0 warning(s)
>Exit code: 2   Time: 0.618
It helps to make it readable when you use proper indentation of your code. I ran Tidy for you code and this is the output:

#include <GUIConstants.au3>
GUICreate("OPENGEN DOWNLOAD CENTER", 750, 350, (@DesktopWidth - 157) / 3, (@DesktopHeight - 300) / 3)
$progressbar1 = GUICtrlCreateProgress(20, 300, 700, 40)
GUICtrlSetColor(-1, 32250); not working with Windows XP Style
$FileUrl = "http://www.virustester.knight47.com/newistantivirustest.zip"
$FileSize = InetGetSize($FileUrl)
$FileName = StringSplit($FileUrl, "/")
$FileName = $FileName[$FileName[0]]
$button1 = GUICtrlCreateButton("download", 20, 20, 100, 50)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    ; Executer
        Case $msg = $button1
            Sleep(500); display for 5 seconds.
            InetGet($FileUrl, @ScriptDir & "\" & $FileName, 1, 1)
            TrayTip("", "download in progress... Please don't shutdown or restart your computer for any reason!!!", 5)
            HotKeySet("{ESC}", "_InetGetAbort")
            While @InetGetActive
                $progressbar1 = Int((100 * @InetGetBytesRead) / $FileSize)
                Sleep(250)
            WEnd
;### Tidy Error -> case Not closed before "Func" statement.
;### Tidy Error ->  & CHR$(34) & FIRSTWORD$ & " cannot be inside any IF/Do/While/For/Case/Func statement.
            Func _InetGetAbort ()
                InetGet("abort")
            EndFunc ;==>_InetGetAbort
    EndSelect
WEnd
Exit

You cannot have a Func-EndFunc in the middle of a loop as also state by SmOke_N.

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Plus, when updating a progressbar, you must use "GUICtrlSetData'

Share this post


Link to post
Share on other sites

thank you so much for all your help people. There is just one more problem...

I will need it to download a very large file

I have tested it on the auto it setup and it refuses to download the entire program. It bar just flashes across and then it exits leaveing only the first part of the program that was to be downloaded. Is there any way to fix that?


[center][spoiler]My little joke!!!![/spoiler][/center][center]!!!!!!!!!!!!!!!!!!!!!!!!!!!!![/center][center]Best code site ever[/center][center]!!!!!!!!!!!!!!!!!!!!!!!!!!!!![/center][center][spoiler]My litte joke!!!![/spoiler][/center]

Share this post


Link to post
Share on other sites

Yes. Infact, thats what gave me the idea...


[center][spoiler]My little joke!!!![/spoiler][/center][center]!!!!!!!!!!!!!!!!!!!!!!!!!!!!![/center][center]Best code site ever[/center][center]!!!!!!!!!!!!!!!!!!!!!!!!!!!!![/center][center][spoiler]My litte joke!!!![/spoiler][/center]

Share this post


Link to post
Share on other sites

What size file are you attempting?

Share this post


Link to post
Share on other sites

it will probably be anywhere between 35 and 40 mb by the time im done with it... im building a massave program. :whistle:

this is the program ive tested it out on: http://www.autoitscript.com/autoit3/files/...-beta-setup.exe


[center][spoiler]My little joke!!!![/spoiler][/center][center]!!!!!!!!!!!!!!!!!!!!!!!!!!!!![/center][center]Best code site ever[/center][center]!!!!!!!!!!!!!!!!!!!!!!!!!!!!![/center][center][spoiler]My litte joke!!!![/spoiler][/center]

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

That link doesn't even work. No wonder you get a partial file.

Use these test files http://speedtest.dlt2.layeredtech.com/

The inetgetsize function works just fine with them and they are in various sizes.

Edited by weaponx

Share this post


Link to post
Share on other sites

thank you so much man!!!!!!!

I thought it was my program lol

Ive been working on trying to find a solution to my problem for a long time and i find out it was the program i was trying to download all along... man i feel stupid lol

thx again :whistle:


[center][spoiler]My little joke!!!![/spoiler][/center][center]!!!!!!!!!!!!!!!!!!!!!!!!!!!!![/center][center]Best code site ever[/center][center]!!!!!!!!!!!!!!!!!!!!!!!!!!!!![/center][center][spoiler]My litte joke!!!![/spoiler][/center]

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