Gimerly Posted April 29, 2014 Posted April 29, 2014 Hello, I have tried to make a progress bar in autoit but it doesn't work properly func _sync () ProgressOn("Download", "Downloading...", "0%") $url = "http://somewebsite.com" $folder = @DesktopCommonDir & "/" $hInet = InetGet($url, $folder, 1, 1 ) ; used to actually retrieve the file $filesize = InetGetSize($url) while Not InetGetInfo($hInet, 2) ; loop until download is finished sleep(500) ; sleep for half a second $BytesRecieved = InetGetInfo($hInet, 0) $Pct = Int($Bytesrecieved /$filesize *100) progressSet($Pct, $Pct & "%") ; set progress bar wend ; destroy the progress bar once the download is complete ProgressOff() endfunc its really weird and has like 0.8% then stops
FireFox Posted April 29, 2014 Posted April 29, 2014 Hi, You need to specify a filename in your InetGet "filename" parameter. Also, I advice you to call InetGetSize before InetGet. Br, FireFox.
Gimerly Posted April 29, 2014 Author Posted April 29, 2014 thanks for the reply FireFox I actually do specify the filename I got rid of it when uploading (sorry I should have used a stub thats my fault.) I tried having putting the get file size function before the actual downloading but the problem still happens. It goes to -0.992871838 then stops and if its a large file to doesn't update the size at all during the download and destroys it self once the download is finished.
CliftonL Posted May 3, 2014 Posted May 3, 2014 I had this problem too and found that some proxy servers will not return the file size to the program. They do however return the bytes received. I used a default file size that is close but not absolute for those situations where a proxy interferes with getting the true file size. A better approach would be to use a php call on the server to filesize( [filename] ) as this would return the file size if the AutoIT function fails to get it. That should get around the proxy issues. Of course, someone else may have a comment on this as well. You should also make sure your server sends headers that set the max-age of your download file to 0 so any proxy server doesn't cache the file and cause even more issues, like not notifying AutoIT of the bytes streamed. Once I did that via .htaccess it helped a lot for my downloadable zip files, etc.
Gimerly Posted May 4, 2014 Author Posted May 4, 2014 Thanks for the reply, I do not have a proxy server at my house. I think maybe its an issue with the function. I am currently looking at WinHttp which can hopefully do a better job
abberration Posted May 4, 2014 Posted May 4, 2014 I basically did the same kind of function for a program I wrote for my job. Mine was different in that I used a Do... Until loop using the the remote file size and the local file size. I have been using it for years with no trouble. Basically, it looks something like this: $remoteFile = "http://somewebsite.com/File.exe" $remoteFileSize = InetGetSize($remoteFile) $download = InetGet($remoteFile) ProgressOn("blah blah blah") Do $localFileSize = FileGetSize(@DesktopDir & "\File.exe") ProgressSet("blah blah blah") Until $localFileSize = $remoteFileSize meoit 1 Easy MP3 | Software Installer | Password Manager
CliftonL Posted May 4, 2014 Posted May 4, 2014 I just tried using a php file which uses filesize() to echo the file size in instances where the file size from InetGetSize() comes up 0. It works great. Still not sure this should be necessary though.
Gimerly Posted May 4, 2014 Author Posted May 4, 2014 Didnt think of using a Do loop, thanks for the assistance
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now