Jump to content

Recommended Posts

Posted

a little rough around the edges in the calculations. should be easy to customize.

Posted Image

#Include <string.au3>
#include <GUIConstants.au3>
ProcessSetPriority("AutoIt3.exe", 0)
GUICreate("Downloader", 156, 230, -1, -1, $WS_SIZEBOX + $WS_SYSMENU)
;;labels
$KBpsInput = GUICtrlCreateInput(0, 4, 48, 55, 17, $ES_RIGHT)
$KBps = GUICtrlCreateLabel("KBps", 63, 50, 250)
$downloadedSoFarInput = GUICtrlCreateInput(0, 4, 70, 55, 17, $ES_RIGHT)
$downloadedSoFar = GUICtrlCreateLabel("MB done", 63, 72, 250)
$lefToDownloadInput = GUICtrlCreateInput(0, 4, 92, 55, 17, $ES_RIGHT)
$leftToDownload = GUICtrlCreateLabel("MB left", 63, 94, 250)
$timeElapsedInput = GUICtrlCreateInput(0, 4, 114, 55, 17, $ES_RIGHT)
$timeElapsed = GUICtrlCreateLabel("Minutes so far", 63, 116, 250)
$timeRemainingInput = GUICtrlCreateInput(0, 4, 136, 55, 17, $ES_RIGHT)
$timeRemaining = GUICtrlCreateLabel("Minutes left", 63, 137, 250)
$percentElapsedInput = GUICtrlCreateInput(0, 4, 158, 55, 17, $ES_RIGHT)
$percentElapsed = GUICtrlCreateLabel("% complete", 63, 161, 250)
$percentRemainingInput = GUICtrlCreateInput(0, 4, 180, 55, 17, $ES_RIGHT)
$percentRemaining = GUICtrlCreateLabel("% remaining", 63, 182, 300)
;others
$myEdit = GUICtrlCreateInput("Paste URI here.", 0, 0, 400, 20)
$button = GUICtrlCreateButton("Download", 3, 23, 60, 20, $BS_CENTER + $BS_VCENTER + $BS_DEFPUSHBUTTON)
$cancel = GUICtrlCreateButton("Cancel", 65, 23, 60, 20, $BS_CENTER + $BS_VCENTER)
GUICtrlSetState($cancel, $GUI_DISABLE)
$progressBar = GUICtrlCreateProgress(135, 25, 15, 173, $PBS_VERTICAL, $PBS_SMOOTH)
GUISetState()
While 1
   $msg = GUIGetMsg()
   If $msg = $GUI_EVENT_CLOSE Then ExitLoop
   If $msg = $cancel Then
      InetGet("abort")
      GUICtrlSetState($button, $GUI_ENABLE)
      GUICtrlSetState($cancel, $GUI_DISABLE)
   EndIf
   If $msg = $button Then
      Call("download")
      GUICtrlSetState($button, $GUI_DISABLE)
      GUICtrlSetState($cancel, $GUI_ENABLE)
   EndIf
WEnd
Func download()
   Global $url = GUICtrlRead($myEdit)
   Global $fileSize = InetGetSize($url)
   Global $startDownloadTime = TimerInit()
   InetGet($url, @DesktopDir & "\" & StringRight($url, StringInStr(_StringReverse($url), "/") - 1), 0, 1)
   AdlibEnable("progress", 1000)
EndFunc  ;==>download
Func progress()
   If @InetGetActive Then
      GUICtrlSetData($KBpsInput, StringFormat("%.3f", (@InetGetBytesRead / 1024) / ( (TimerDiff($startDownloadTime) / 1000))))
      GUICtrlSetData($downloadedSoFarInput, StringFormat("%.2f", (@InetGetBytesRead / 1024) / 1024))
      GUICtrlSetData($lefToDownloadInput, StringFormat("%.2f", ($fileSize / 1024) - (@InetGetBytesRead / 1024) / 1024))
      GUICtrlSetData($timeElapsedInput, StringFormat("%.2f", 60 - (3600000 - TimerDiff($startDownloadTime)) / 60000))
      GUICtrlSetData($timeRemainingInput, StringFormat("%.2f", 60 - (3600000 - ( ($fileSize - @InetGetBytesRead) / @InetGetBytesRead) * TimerDiff($startDownloadTime)) / 60000))
      GUICtrlSetData($percentElapsedInput, StringFormat("%.2f", (@InetGetBytesRead / $fileSize) * 100))
      GUICtrlSetData($percentRemainingInput, StringFormat("%.2f", (100 - (@InetGetBytesRead / $fileSize) * 100)))
      GUICtrlSetData($progressBar, (@InetGetBytesRead / $fileSize) * 100)
   EndIf
   If @InetGetActive = 0 Then
      GUICtrlSetState($button, $GUI_ENABLE)
      GUICtrlSetState($cancel, $GUI_DISABLE)
      AdlibDisable()
   EndIf
EndFunc  ;==>progress

ps: syntax check does not recognize InetGet("abort")

  • Developers
Posted (edited)

  Alterego said:

ps: syntax check does not recognize InetGet("abort")

<{POST_SNAPBACK}>

You mean it does recognise it but gives an error like:

ERROR: InetGet() [built-in] called with wrong number of args.

Thats because the helpfile states:

InetGet ( "URL", "filename" [, reload [, background]] )

And the config file for au3check is generated based on this syntax. o:)

:lmao: Maybe the abort functionallity syntax should be: InetGet("abort","") ????

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

I don't see a problem with the current syntax. It would be nice if the help file had some way to properly reflect it, however, this is a perfect use for the Au3Check override section of AutoIt Extractor.

  • Developers
Posted (edited)

  Valik said:

I don't see a problem with the current syntax.  It would be nice if the help file had some way to properly reflect it, however, this is a perfect use for the Au3Check override section of AutoIt Extractor.

<{POST_SNAPBACK}>

Nah... not really... its always needs minimal 2 parameters except when "Abort" is specified for the first parameter... so: "6=InetGet 1 4" leaves room for syntax error ... right ? Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

  JdeB said:

Nah... not really...  its always needs minimal 2 parameters except when "Abort" is specified for the first parameter...  so: "6=InetGet 1 4"  leaves room for syntax error ... right ?

<{POST_SNAPBACK}>

Fair enough (Since you maintain a public distribution with people of questionable intelligence, I won't argue the point). Maybe the best alternative would just be a seperate function. That makes the most sense to me anyway.
  • Developers
Posted

  Valik said:

Maybe the best alternative would just be a seperate function.  That makes the most sense to me anyway.

<{POST_SNAPBACK}>

That would work too....

In the mean time i will put the override in anyway just to avoid getting the au3check error on InetGet("abort")....

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

i downloaded a file with it and it didn't show 100% when it finished, i don't know how you could fix that but its a bug :lmao:

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...