Jump to content

InetGetSize freezes GUI when used with FTP downloads


DigDeep
 Share

Recommended Posts

Hi,

I am facing a weird situation here. Not sure how to explain though.

I have multiple GUI applications built in past where I am using Progress bars for both Internet as well as Intranet downloads and they have been working fine. But now I am getting a new application which is not downloading any files from any of the FTP sites.

I found that the complete GUI freezes up when it reaches to the line:

InetGetSize($SourcePath)

I tested by building a new GUI by getting only the function for Progress window and it works fine. But in the new GUI application it only freezes up when trying to download anything from FTPs. Internet file downloads are working all good though.

 

Below is the example I had just created taking the Progress window part only and it work here but not in the main GUI.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 593, 233, 774, 427)
$Label1 = GUICtrlCreateLabel("File Download", 200, 40, 197, 28, $SS_CENTER)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")

$GetFileButton = GUICtrlCreateButton("Get File", 264, 184, 75, 25, $BS_DEFPUSHBUTTON)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $GetFileButton

            $Progress1 = GUICtrlCreateProgress(168, 120, 270, 17)
            Local $SourcePath = "FTP file path" ; Test file

            $Dest = "C:\Temp\TestFileName.exe" ; Download Dest Path
            $GetFile = InetGet($SourcePath, $Dest, 1, 1) ;Forces a reload from the remote site and return immediately and download in the background
            $SourcePathSize = InetGetSize($SourcePath) ;Get file size

            Do
                Sleep(100) ;Sleep for half a second to avoid flicker in the progress bar
                $GetDownldBytes1 = InetGetInfo($GetFile, 0) ; Get number of bytes read for current file
                $GetDownldPerct1 = Int($GetDownldBytes1 / $SourcePathSize * 100) ;Calculate percentage
                $Totalsize1 = $SourcePathSize - $GetDownldBytes1
                GUICtrlSetData($Progress1, $GetDownldPerct1) ; Update the Current FIle progress bar
            Until InetGetInfo($GetFile, 2) ; Continue loop until download is complete

    EndSwitch
WEnd

 

 

Any suggestions I can try out here?

 

 

 

Edited by DigDeep
Link to comment
Share on other sites

  • Moderators

Post working code to fix non working (non posted) code issue?

That's like taking a car to a mechanic but asking him to diagnose your car that still sitting in your driveway at home.

Edited by SmOke_N

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.

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...