qwerz123 Posted December 29, 2013 Posted December 29, 2013 Hello! I need to create a script that just check the internet connection. I was thinking that i don't need to wait till all the bytes are downloaded. Just if some of them are downloaded - it's enough and internet working fine. So i created a simple script for testing: Local $bytesRead = 0 Local $hDownload1 = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", @TempDir & "\update.dat", 1, 1) While $bytesRead = 0 $bytesRead = InetGetInfo($hDownload1, 0) ConsoleWrite("In While. Bytes read: " & $bytesRead & @CRLF) WEnd InetClose($hDownload1) ; Close the handle to release resources. In real script i will add the Sleep function but for testing purposes it is without it. So in my console i see only this: In While. Bytes read: 0 In While. Bytes read: 0 In While. Bytes read: 0 ... etc the same In While. Bytes read: 452 So for some reason the function does not return the bytes read so far and only return when the whole downloading is complete. Could anyone help me or point me where i did the mistake? Best regards
Solution JohnOne Posted December 29, 2013 Solution Posted December 29, 2013 I'd hazard a guess that 452 bytes is downloaded in one chunk, there's nothing, then 452 bytes. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
qwerz123 Posted December 29, 2013 Author Posted December 29, 2013 (edited) I'd hazard a guess that 452 bytes is downloaded in one chunk, there's nothing, then 452 bytes. Yes, you're right. I just tested with a little different script. While $bytesRead = 0 $bytesRead = InetGetInfo($hDownload1, 0) WEnd Do Sleep(250) Until InetGetInfo($hDownload1, 2) ; Check if the download is complete. Local $total = InetGetInfo($hDownload1, 0) InetClose($hDownload1) ; Close the handle to release resources. ConsoleWrite("Bytes read: " & $bytesRead & @CRLF) ConsoleWrite("Total: " & $total & @CRLF) And it gave me: Bytes read: 3806 Total: 176351 So yes, your answer is correct. Best regards Edited December 29, 2013 by qwerz123
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