Sign in to follow this  
Followers 0
MerkurAlex

download with progressbar

18 posts in this topic

i was wondering if someone could give me an example of a download using a progress bar to check the download percent


[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites



no one knows?


[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites

$DownloadURL = "http://www.autoitscript.com/autoit3/files/beta/autoit/autoit-v3.2.3.14-beta-setup.exe"
$FileName = StringRight($DownloadURL,StringLen($DownloadURL) - StringInStr($DownloadURL,"/",0,-1))

$size = InetGetSize($DownloadURL)

InetGet($DownloadURL,@scriptdir & "\" & $FileName, 1, 1)

ProgressOn("Downloading " & $FileName,"")
     While @InetGetActive
          $prog = (100 * @InetGetBytesRead) / $size
          ProgressSet($prog, @InetGetBytesRead & "/" & $size & " bytes", "Downloading")
          Sleep(250)
     WEnd
ProgressOff()

Share this post


Link to post
Share on other sites

Dammit you beat me to it. I'm posting anyways.

$URL = "http://www.rarlab.com/rar/wrar370.exe"
$FILENAME = "wrar370.exe"

$FILESIZE = InetGetSize ( $URL )

InetGet($URL, $FILENAME, 1, 1)

ProgressOn("Download progress", "", "0%")

While @InetGetActive
    $PERCENT = Int((@InetGetBytesRead / $FILESIZE) * 100)
    ProgressSet( $PERCENT, $PERCENT & " %")

    ;TrayTip("Downloading", "Bytes = " & @InetGetBytesRead & @CRLF & $PERCENT & " %", 10, 16)
    
    ;Enable sleep to reduce flickering
    ;Sleep(250)
Wend

Share this post


Link to post
Share on other sites

ChrisL your method for determining the filename is odd. You should just use:

$A = StringSplit($URL, "/")
$FILENAME = $A[$A[0]]

Share this post


Link to post
Share on other sites

Hmm, i noted the differences, and figured i would have a crack at combining them, just because i was bored, here is my attempt (i added a way to cancel th download)

$FileUrl = "http://www.autoitscript.com/autoit3/files/beta/autoit/autoit-v3.2.3.14-beta-setup.exe"
$FileSize = InetGetSize($FileUrl)
$FileName = StringSplit($FileUrl, "/")
$FileName = $FileName[$FileName[0]]

InetGet($FileUrl,@scriptdir & "\" & $FileName, 1, 1)

HotKeySet("{ESC}", "_InetGetAbort")

ProgressOn("Download progress for "&$FileName, "", "0%")
While @InetGetActive
    $Prog = Int((100 * @InetGetBytesRead) / $FileSize)
    ProgressSet($prog, @InetGetBytesRead & "/" & $FileSize & " bytes", "Downloading "&$FileName)
    Sleep(250)
WEnd

Func _InetGetAbort()
    InetGet("abort")
EndFunc ;==> _InetGetAbort()

Share this post


Link to post
Share on other sites

thanks guys.


[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites

I save .018 milliseconds

; Script Start - Add your code below here
$URL = "http://www.rarlab.com/rar/wrar370.exe"

;Benchmark 1
$TIMER1 = TimerInit ()

$A = StringSplit($URL, "/")
$FILENAME = $A[$A[0]]

$L1 = TimerDiff ($TIMER1)

;Benchmark 2
$TIMER2 = TimerInit ()

$FileName = StringRight($URL,StringLen($URL) - StringInStr($URL,"/",0,-1))

$L2 = TimerDiff ($TIMER2)

MsgBox(0,"","Timer1: " & $L1 & @CRLF & "Timer2: " & $L2 & @CRLF & "Difference: " & ($L2 - $L1) & "ms")

Share this post


Link to post
Share on other sites

Win some loose some I'd say

lol I was just joking. Speed definitely isn't an issue in this case but if it had to be done 100,000 times there would be a noticeable difference.

Share this post


Link to post
Share on other sites

lol I was just joking. Speed definitely isn't an issue in this case but if it had to be done 100,000 times there would be a noticeable difference.

Did you look at the attachment? On my laptop sometimes yours was faster and sometimes mine was. I think it depends on which way the wind is blowing :whistle:

Share this post


Link to post
Share on other sites

Did you look at the attachment? On my laptop sometimes yours was faster and sometimes mine was. I think it depends on which way the wind is blowing :whistle:

can you but this in a gui with abutton to start it/...


Ok im 14 with a spelling age of a 9 year old... that explanes all my spelling mistakes

Share this post


Link to post
Share on other sites

You can get the name even easyer...

$FileName = StringRegExpReplace($URL, "^.*\\", "")

:whistle:


Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

You can get the name even easyer...

$FileName = StringRegExpReplace($URL, "^.*\\", "")oÝ÷ Øÿêº^} EjË^²ÛޮȨ'­jëh×6; Script Start - Add your code below here
$URL = "http://www.rarlab.com/rar/wrar370.exe"

;Benchmark 1
$TIMER1 = TimerInit ()

$A = StringSplit($URL, "/")
$FILENAME = $A[$A[0]]

$L1 = TimerDiff ($TIMER1)

;Benchmark 2
$TIMER2 = TimerInit ()

$FileName = StringRight($URL,StringLen($URL) - StringInStr($URL,"/",0,-1))

$L2 = TimerDiff ($TIMER2)

;Benchmark 3
$TIMER3 = TimerInit ()

$FileName = StringRegExpReplace($URL, "^.*\\", "")

$L3 = TimerDiff ($TIMER3)

MsgBox(0,"","Timer1: " & $L1 & @CRLF & "Timer2: " & $L2 & @CRLF & "Timer3: " & $L3)

Share this post


Link to post
Share on other sites

For URL i forgot, it must be with one backslash:

$FileName = StringRegExpReplace($URL, "^.*/", "")

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Hmm, i noted the differences, and figured i would have a crack at combining them, just because i was bored, here is my attempt (i added a way to cancel th download)

$FileUrl = "http://www.autoitscript.com/autoit3/files/beta/autoit/autoit-v3.2.3.14-beta-setup.exe"
$FileSize = InetGetSize($FileUrl)
$FileName = StringSplit($FileUrl, "/")
$FileName = $FileName[$FileName[0]]

InetGet($FileUrl,@scriptdir & "\" & $FileName, 1, 1)

HotKeySet("{ESC}", "_InetGetAbort")

ProgressOn("Download progress for "&$FileName, "", "0%")
While @InetGetActive
    $Prog = Int((100 * @InetGetBytesRead) / $FileSize)
    ProgressSet($prog, @InetGetBytesRead & "/" & $FileSize & " bytes", "Downloading "&$FileName)
    Sleep(250)
WEnd

Func _InetGetAbort()
    InetGet("abort")
EndFunc ;==> _InetGetAbort()

Just a litle question?

Why do I get an empty file

Can someone help me

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Excuse me for interrupting the willy waving :) but does anytone know if there is a way of having the progress bar follow a data transfer without using InetGet?

Edited by Memnoch

Share this post


Link to post
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
Sign in to follow this  
Followers 0