Sign in to follow this  
Followers 0
Truffle

GUI wont update

7 posts in this topic

I wrote a script almost exactly like the one im gonna paste here that downloaded a file from the net showing a progress bar and when reached 100% it let you know.

I wrote it two months ago and it worked fine. Now I cant click on Cancel and no progress bar moves until the end of the download because the GUI is locked up.

The code im going to post may look a little weird because A) I wrote it. B) I messed with it quite a bit hoping to get the progress bar to move

#include <GuiConstants.au3>

GuiCreate("Downloader", 392, 195,(@DesktopWidth-392)/2, (@DesktopHeight-195)/2 , $WS_VISIBLE + $WS_CLIPSIBLINGS)
DirRemove("C:\dltmp",1)
#region --- Start Defining GUI Controls ---

$progressbar1 = GuiCtrlCreateProgress(20, 40, 350, 30)

$cancelButton = GuiCtrlCreateButton("Cancel", 140, 130, 80, 25)
$exitButton = GuiCtrlCreateButton("Exit", 140, 130, 85, 25)
#endregion --- End of GUI Controls ---
$fileSize = InetGetSize("http://www.olhideout.net/maps/spacewar.zip")

GUICtrlSetState($exitButton,$GUI_HIDE)
DirCreate("C:\dltmp")
$downloading = 1
sleep(1000)
InetGet("http://www.olhideout.net/maps/spacewar.zip","C:\dltmp\spacewar.zip")

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $exitButton
        ExitLoop
    case $msg = $cancelButton
        InetGet("abort")
    Case Else
    ;;;
    EndSelect
WEnd    
While $downloading = 1

    $p = INT( (@InetGetBytesRead/$fileSize) * 100)
    
    GUICtrlSetData ($progressbar1,$p)
    
    if @InetGetBytesRead = $fileSize Then
        $downloading = 0
        GUICtrlSetState($cancelButton,$GUI_HIDE)
        GUICtrlSetState($exitButton,$GUI_SHOW)
        $continue = MsgBox(64,"Download Completed","Your Download Has Finished")
        if $continue = 1 Then
        EndIf
    
    EndIf
    
WEnd
Exit

If I replace while downloading = 1 with while @InetGetActive I get the same result plus no messagebox at the end. I'm not even sure if Autoit is acknowledging the @InetGetActive. I tried it on the latest Beta and on the latest Stable release.

Help! Please :) Is it just my computer? I thought so at first until I tried it on my second PC.

Share this post


Link to post
Share on other sites



Your script will never go out of the first while loop unless you close the GUI or you click on the exit button So it is normal you never execute the second while whatever the condition you are using. :)

Share this post


Link to post
Share on other sites

well it was originally like this (ive been messing with the code i must have forgotten to change it back

While 1

$msg = GuiGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

  ExitLoop

Case $msg = $exitButton

  ExitLoop

case $msg = $cancelButton

  InetGet("abort")

Case Else

  ;;;

EndSelect

If @InetGetActive Then

$p = INT( (@InetGetBytesRead/$fileSize) * 100)

GUICtrlSetData ($progressbar1,$p)

if @InetGetBytesRead = $fileSize Then

  $downloading = 0

  GUICtrlSetState($cancelButton,$GUI_HIDE)

  GUICtrlSetState($exitButton,$GUI_SHOW)

  $continue = MsgBox(64,"Download Completed","Your Download Has Finished")

  if $continue = 1 Then

  EndIf

EndIf

EndIf

WEnd

Exit

The GUI still locks up

Share this post


Link to post
Share on other sites

InetGet("http://www.olhideout.net/maps/spacewar.zip","C:\dltmp\spacewar.zip",1,1)

your inetget must allow download in background as above

Share this post


Link to post
Share on other sites

InetGet("http://www.olhideout.net/maps/spacewar.zip","C:\dltmp\spacewar.zip",1,1)

your inetget must allow download in background as above

<{POST_SNAPBACK}>

cool! Thanks...

Another question (sorry) where does Autoit cache these downloads? Im deleting the file it downloads and later I download a 3 MB file in 1 second... even after reboot.

Share this post


Link to post
Share on other sites

cool! Thanks...

Another question (sorry) where does Autoit cache these downloads? Im deleting the file it downloads and later I download a 3 MB file in 1 second... even after reboot.

<{POST_SNAPBACK}>

it is not AutoIt but the proxy/firewall that's you certainly have before the data reach your computer.

I am supprised it can be so fast with the force reload parameter on as I suggest.

What kind of link speed are you using to access the internet? :)

Share this post


Link to post
Share on other sites

I download at 27 Kilobytes a second. I do use a proxy server. I turned off the server and dialed in on my dial up account. And it still downloaded the 3 meg file in a second... However this was before the reload parameter so I will try again when I get home.

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