speeder Posted December 17, 2007 Posted December 17, 2007 When i am downloading a file with InetGet i want a window to show how many bytes already have been downloaded and how many are left. I tried it via a msgbox via InetGetActive but i can't get it to show while the InetGet line is still busy. How can i get this to work.
Nahuel Posted December 17, 2007 Posted December 17, 2007 (edited) Something like this I guess: $File="http://www.autoitscript.com/autoit3/files/beta/autoit/autoit-v3.2.10.0-rc-setup.exe" $size = InetGetSize($File) ProgressOn ( "Downloading " & $File, "0% downloaded" , $size & " bytes remaining" ) InetGet($File,@DesktopDir & "\autoit-v3.2.10.0-rc-setup.exe",1,1) While @InetGetActive $Percent=Int((@InetGetBytesRead*100)/$size) $Remain=$size-@InetGetBytesRead ProgressSet( $Percent,$Remain & " bytes remaining", $Percent & "% downloaded") Sleep(100) WEnd ProgressOff() MsgBox(0,"Download complete",@DesktopDir & "\autoit-v3.2.10.0-rc-setup.exe") But you could make your custom GUI and display more information. Look at the macros and functions I used. Edited December 17, 2007 by Nahuel
Confuzzled Posted December 17, 2007 Posted December 17, 2007 Something like this I guess: $File="http://www.autoitscript.com/autoit3/files/beta/autoit/autoit-v3.2.10.0-rc-setup.exe" $size = InetGetSize($File) ProgressOn ( "Downloading " & $File, "0% downloaded" , $size & " bytes remaining" ) InetGet($File,@DesktopDir & "\autoit-v3.2.10.0-rc-setup.exe",1,1) While @InetGetActive $Percent=Int((@InetGetBytesRead*100)/$size) $Remain=$size-@InetGetBytesRead ProgressSet( $Percent,$Remain & " bytes remaining", $Percent & "% downloaded") Sleep(100) WEnd ProgressOff() MsgBox(0,"Download complete",@DesktopDir & "\autoit-v3.2.10.0-rc-setup.exe") But you could make your custom GUI and display more information. Look at the macros and functions I used.How about using the traytip like in the helpfile example? Note that I'm updating every half second (sleep 500) rather than 10 times a second (sleep 100) and avoiding too many arithmetic operations within the loop to prevent too many overheads. ;Get size of file to download $Inet_size = InetGetSize($FileNameToDownloadURL) ;Get the file and update progress status every half second in Traytip InetGet($FileNameToDownloadURL, @ScriptDir & "\$FileNameToSave", 1, 1) While @InetGetActive TrayTip("Getting file", "Bytes = " & @InetGetBytesRead & "/" & $Inet_size, 10, 17) ; Update progress bar here Sleep(500) Wend TrayTip("Got file", "Bytes = " & @InetGetBytesRead & "/" & $Inet_size, 10, 17); Final amount Sleep(2000) ;Give it time to finish download and close file and the antivirus program to check it so it is not still in use TrayTip ("", "", 0,0) ; Turn off traytip How about combining the two for a really professional finish?
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