HAL9000 0 Posted August 25, 2010 How to show a progress bar during download? with old version of autoit, i used $size = InetGetSize("link") While @InetGetActive GUICtrlSetData ($progressbar,Ceiling((@InetGetBytesRead/$size)*100)) Wend but with new version i have problems to do the same thing with InetGetInfo Share this post Link to post Share on other sites
FlyinRiz 0 Posted August 25, 2010 How to show a progress bar during download? with old version of autoit, i used $size = InetGetSize("link") While @InetGetActive GUICtrlSetData ($progressbar,Ceiling((@InetGetBytesRead/$size)*100)) Wend but with new version i have problems to do the same thing with InetGetInfo $handle = InetGet("link") InetGetSize("link") = InetGetInfo($handle,1) @InetGetActive = InetGetInfo($handle,2) @InetGetBytesRead = InetGetInfo($handle,0) This was all in the help file and explained very well. If you need more info on this, I would start there. I've never actually used these functions before and was able to find the info in under 60 seconds. So in the future, I would do a little leg work before you ask someone to help you. That will make people want to help you more, knowing that you've actually tried first. -Aaron Share this post Link to post Share on other sites
GMK 25 Posted August 25, 2010 (edited) Not sure if this is the best, most efficient way to do it, but here's what I've done:ProgressOn("Download", "Downloading...", "0%") $url= "http://www.domain.com/folder/file.txt" ;Set URL $folder = @MyDocumentsDir & "\downloads\" ;Set folder $hInet = InetGet($url, $folder, 1, 1) ;Forces a reload from the remote site and return immediately and download in the background $FileSize = InetGetSize($url) ;Get file size While Not InetGetInfo($hInet, 2) ;Loop until download is finished Sleep(500) ;Sleep for half a second to avoid flicker in the progress bar $BytesReceived = InetGetInfo($hInet, 0) ;Get bytes received $Pct = Int($BytesReceived / $FileSize * 100) ;Calculate percentage ProgressSet($Pct, $Pct & "%") ;Set progress bar WEnd ProgressOff() Edited August 25, 2010 by GMK Share this post Link to post Share on other sites
wakillon 403 Posted August 25, 2010 (edited) How to show a progress bar during download? For example... #include <Math.au3> $_FinalUrl = 'http://www.birdscanfly.com/images/bcf_wallpaper_1440.jpg' $_TempPath = @TempDir & '\bcf_wallpaper_1440.jpg' $_FileSize = InetGetSize ( $_FinalUrl ) $_Gui = GUICreate ( "" ) $_ProgressBar = GUICtrlCreateProgress ( 5, 25, 350, 23 ) GUISetState ( @SW_SHOW ) $_Download = InetGet ( $_FinalUrl, $_TempPath, 1, 1 ) Local $_InfoData Do $_InfoData = InetGetInfo ( $_Download ) If Not @error Then $_InetGet = $_InfoData[0] $_DownloadPercent = Round ( ( 100 * $_InetGet ) / $_FileSize ) $_DownloadPercent = _Min ( _Max ( 1, $_DownloadPercent ), 99 ) GUICtrlSetData ( $_ProgressBar, $_DownloadPercent ) $_Label = GUICtrlCreateLabel ( 'progress : ' & $_DownloadPercent & ' %', 5, 52, 350, 20 ) EndIf Sleep ( 100 ) Until $_InfoData[2] = True $_Label = GUICtrlCreateLabel ( 'Download successfull !', 5, 52, 350, 20 ) Sleep ( 2000 ) sorry GMK, i doesn't see your post ! Edited August 25, 2010 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Share this post Link to post Share on other sites
guinness 1,518 Posted August 25, 2010 @FlyinRiz - seems you have an old version of AutoIt as @InetGetActive and @InetGetBytesRead were removed in V3.3.4.0This was pulled from the HelpFile, but the examples shown above seem to do the trick.#Alternate Local $hDownload = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", @TempDir & "\update.dat", 1, 1) Do Sleep(250) Until InetGetInfo($hDownload, 2) ; Check if the download is complete. Local $aData = InetGetInfo($hDownload) ; Get all information. InetClose($hDownload) ; Close the handle to release resourcs. MsgBox(0, "", "Bytes read: " & $aData[0] & @CRLF & _ "Size: " & $aData[1] & @CRLF & _ "Complete?: " & $aData[2] & @CRLF & _ "Successful?: " & $aData[3] & @CRLF & _ "@error: " & $aData[4] & @CRLF & _ "@extended: " & $aData[5] & @CRLF) UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Share this post Link to post Share on other sites
HAL9000 0 Posted August 26, 2010 Not sure if this is the best, most efficient way to do it, but here's what I've done: ProgressOn("Download", "Downloading...", "0%") $url= "http://www.domain.com/folder/file.txt" ;Set URL $folder = @MyDocumentsDir & "\downloads\" ;Set folder $hInet = InetGet($url, $folder, 1, 1) ;Forces a reload from the remote site and return immediately and download in the background $FileSize = InetGetSize($url) ;Get file size While Not InetGetInfo($hInet, 2) ;Loop until download is finished Sleep(500) ;Sleep for half a second to avoid flicker in the progress bar $BytesReceived = InetGetInfo($hInet, 0) ;Get bytes received $Pct = Int($BytesReceived / $FileSize * 100) ;Calculate percentage ProgressSet($Pct, $Pct & "%") ;Set progress bar WEnd ProgressOff() works :-) Share this post Link to post Share on other sites
HAL9000 0 Posted August 26, 2010 For example... #include <Math.au3> $_FinalUrl = 'http://www.birdscanfly.com/images/bcf_wallpaper_1440.jpg' $_TempPath = @TempDir & '\bcf_wallpaper_1440.jpg' $_FileSize = InetGetSize ( $_FinalUrl ) $_Gui = GUICreate ( "" ) $_ProgressBar = GUICtrlCreateProgress ( 5, 25, 350, 23 ) GUISetState ( @SW_SHOW ) $_Download = InetGet ( $_FinalUrl, $_TempPath, 1, 1 ) Local $_InfoData Do $_InfoData = InetGetInfo ( $_Download ) If Not @error Then $_InetGet = $_InfoData[0] $_DownloadPercent = Round ( ( 100 * $_InetGet ) / $_FileSize ) $_DownloadPercent = _Min ( _Max ( 1, $_DownloadPercent ), 99 ) GUICtrlSetData ( $_ProgressBar, $_DownloadPercent ) $_Label = GUICtrlCreateLabel ( 'progress : ' & $_DownloadPercent & ' %', 5, 52, 350, 20 ) EndIf Sleep ( 100 ) Until $_InfoData[2] = True $_Label = GUICtrlCreateLabel ( 'Download successfull !', 5, 52, 350, 20 ) Sleep ( 2000 ) sorry GMK, i doesn't see your post ! also this works but i have changed the code #include <Math.au3> $_DownloadPercent=0 $_Gui = GUICreate ( "" ) $_ProgressBar = GUICtrlCreateProgress ( 5, 25, 350, 23 ) $_Label = GUICtrlCreateLabel ($_DownloadPercent & ' %', 360, 30, 40,20 ) GUISetState ( @SW_SHOW ) $_FinalUrl = 'http://www.shapecollage.com/2.5/ShapeCollage-2.5-Setup.exe' $_TempPath = @scriptDir & "\ShapeCollage-2.5-Setup.exe" $_FileSize = InetGetSize ( $_FinalUrl ) $_Download = InetGet ( $_FinalUrl, $_TempPath, 1, 1 ) Local $_InfoData Do Sleep ( 500 ) $_InfoData = InetGetInfo ( $_Download ) If Not @error Then $_InetGet = $_InfoData[0] $_DownloadPercent = Round ( ( 100 * $_InetGet ) / $_FileSize ) $_DownloadPercent = _Min ( _Max ( 1, $_DownloadPercent ), 99 ) GUICtrlSetData ( $_ProgressBar, $_DownloadPercent ) GUICtrlSetData ( $_Label, $_DownloadPercent & ' %') EndIf Until $_InfoData[2] = True GUICtrlCreateLabel ( 'Download successfull !', 5, 52, 350, 20 ) Sleep ( 2000 ) Share this post Link to post Share on other sites
HAL9000 0 Posted August 26, 2010 (edited) $handle = InetGet("link") InetGetSize("link") = InetGetInfo($handle,1) @InetGetActive = InetGetInfo($handle,2) @InetGetBytesRead = InetGetInfo($handle,0) This was all in the help file and explained very well. If you need more info on this, I would start there. I've never actually used these functions before and was able to find the info in under 60 seconds. So in the future, I would do a little leg work before you ask someone to help you. That will make people want to help you more, knowing that you've actually tried first. -Aaron Yes I know, I am a stupid boy, sorry Edited August 26, 2010 by HAL9000 Share this post Link to post Share on other sites
wakillon 403 Posted August 26, 2010 The main thing is that it works!glad I could help AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Share this post Link to post Share on other sites