Shyke Posted November 28, 2005 Posted November 28, 2005 This is another one of the things that I have never known how to do... make a progress bar move to the percentage of the file downloaded. Can anyone clue me in on how to do this without saying "Go look at the AutoIt update au3 file"?
Valuater Posted November 28, 2005 Posted November 28, 2005 this would be a great one to look athttp://www.autoitscript.com/forum/index.ph...st=0&p=1168858)
Sokko Posted November 28, 2005 Posted November 28, 2005 Ultra-simplified example: $size = InetGetSize("http://www.website.com/file.ext") InetGet("http://www.website.com/file.ext","C:\directory\file.ext",0,1) While @InetGetActive GUICtrlSetData($progressbar,@InetGetBytesRead/$size) WEnd The main point is that you get the total size of the file, then download it in background mode and update the progress bar with the ratio of bytes downloaded to bytes total (progress bars take percentage values for data setting).
Skuller74 Posted November 29, 2005 Posted November 29, 2005 Hey sorry for this question. but, say, you were making a downloader, and you ask the user to input the file URL and the folder for download, say these are variabls $URL and $Folder would you have this... $size = InetGetSize($URL) InetGet($URL,$Folder,0,1)
Valuater Posted November 29, 2005 Posted November 29, 2005 (edited) Hey sorry for this question. but, say, you were making a downloader, and you ask the user to input the file URL and the folder for download, say these are variabls $URL and $Folder would you have this... $size = InetGetSize($URL) InetGet($URL,$Folder,0,1) yes... but its actually a file not folder 8) Edited November 29, 2005 by Valuater
Shyke Posted November 29, 2005 Author Posted November 29, 2005 (edited) I have: $size = InetGetSize($link) InetGet($link, $Path & "test.zip", 1, 1) While @InetGetActive GUICtrlSetData($DownloadBar, @InetGetBytesRead / $size) WEnd And it doesn't work for some reason... anyone help? EDIT: I think it could hgave something to do with the additional code right under that: Do $bartest = GUICtrlRead($DownloadBar) If $bartest = 100 Then $bar = 1 GUICtrlSetState($DownloadBar, $GUI_Hide) GUICtrlSetState($DownloadDone, $GUI_Show) EndIf WorkIt() Until $bar = 1 EDIT: I put WorkIt() inside the If so now it doesn't spam, lol Edited November 29, 2005 by Shyke
Shyke Posted November 30, 2005 Author Posted November 30, 2005 Can no one help? Note: I only double posted because I really don't know...
LxP Posted December 1, 2005 Posted December 1, 2005 I'm a bit confused by a couple of the things that you have posted. Could you please post a complete piece of code and explain what's wrong?
GaryFrost Posted December 1, 2005 Posted December 1, 2005 Hey sorry for this question. but, say, you were making a downloader, and you ask the user to input the file URL and the folder for download, say these are variabls $URL and $Folder would you have this... $size = InetGetSize($URL) InetGet($URL,$Folder,0,1) As Valuater posted earlier, might be a good idea to take a look at Small download tool SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
powaking Posted December 2, 2005 Posted December 2, 2005 (edited) As Valuater posted earlier, might be a good idea to take a look at Small download tool Threw this together real quick. Its probably dirty as hell but I'm still learning AutoIt. This will download and execute the file and immediately exit out of itself. If you can figure out how to put the percentage inside the bar without interferring with the bar and not having to use a Beta of autoit let me know Try it out. expandcollapse popup#include <GUIConstants.au3> #include <array.au3> #include <file.au3> #include <inet.au3> #include <process.au3> GUICreate("Download", 250, 250, 300, 100) GUICtrlCreateLabel("Path", 20, 10, 50, 20) $path = GUICtrlCreateInput("", 50, 10, 170, 15, $ES_AUTOHSCROLL, "") GUICtrlCreateLabel("Save: ", 20, 30, 50, 20) $save = GUICtrlCreateInput("", 50, 30, 170, 15, $ES_AUTOHSCROLL, "") $Download = GUICtrlCreateProgress(30, 160, 180, 20, "",$PBS_SMOOTH) GUICtrlCreateGroup("Status ", 20, 60, 200, 135) GUICtrlCreateLabel("File Remaining: ", 25, 85, 140, 20) GUICtrlCreateLabel("Percent done: ", 25, 110, 120, 20) GUICtrlCreateLabel("Size: ", 25, 135, 75, 20) $btn = GUICtrlCreateButton("Download", 90, 205, 60, 20, $BS_DEFPUSHBUTTON) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $btn $size = InetGetSize(GUICtrlRead($path)) InetGet(GUICtrlRead($path), GUICtrlRead($save), 1, 1) GUICtrlCreateLabel(Round(StringTrimRight("" & $size / 1024, 3)) & " KB", 60, 135, 75, 25) While @InetGetActive For $i = @InetGetBytesRead To $size GUICtrlCreateLabel(StringTrimRight("" & $size - @InetGetBytesRead, 6) & " MB", 110, 85, 35, 35) $i_StatusPercent = (@InetGetBytesRead / $size * 100) GUICtrlCreateLabel(Round($i_StatusPercent) & "%", 100, 110, 25, 15, $SS_CENTER) GUICtrlSetData($Download, $i_StatusPercent) Sleep(400) If round($i_statuspercent) = "100" Then ExitLoop EndIf Next Run(guictrlread($save)) Exit WEnd EndSelect WEnd Exit Edited December 3, 2005 by powaking
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