<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Прогресс загрузки файла]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=11669</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11669&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Прогресс загрузки файла».]]></description>
		<lastBuildDate>Sun, 05 Jun 2016 03:17:19 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Прогресс загрузки файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=104712#p104712</link>
			<description><![CDATA[<p><strong>ypppu</strong>, спасибо.</p><p>Может пригодится кому-то:<br /></p><div class="codebox"><pre><code>
Url            = https://www.autohotkey.com/download/ahk-install.exe
	DownloadAs     = ahk.exe
	Overwrite      := True 
	UseProgressBar := True
	DownloadFile(Url, DownloadAs, Overwrite, UseProgressBar)
	

;=================== Start Functions =====================================================================

DownloadFile(UrlToFile, SaveFileAs, Overwrite := True, UseProgressBar := True) {
    ;Check if the file already exists and if we must not overwrite it
      If (!Overwrite &amp;&amp; FileExist(SaveFileAs))
          Return
    ;Check if the user wants a progressbar
      If (UseProgressBar) {
          ;Initialize the WinHttpRequest Object
            WebRequest := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
          ;Download the headers
            WebRequest.Open(&quot;HEAD&quot;, UrlToFile)
            WebRequest.Send()
          ;Store the header which holds the file size in a variable:
            FinalSize := WebRequest.GetResponseHeader(&quot;Content-Length&quot;)
          ;Create the progressbar and the timer
            Progress, H80, , Downloading..., %UrlToFile%
            SetTimer, __UpdateProgressBar, 100
      }
    ;Download the file
      UrlDownloadToFile, %UrlToFile%, %SaveFileAs%
    ;Remove the timer and the progressbar because the download has finished
      If (UseProgressBar) {
          Progress, Off
          SetTimer, __UpdateProgressBar, Off
      }
    Return
    
    ;The label that updates the progressbar
      __UpdateProgressBar:
          ;Get the current filesize and tick
            CurrentSize := FileOpen(SaveFileAs, &quot;r&quot;).Length ;FileGetSize wouldn&#039;t return reliable results
            CurrentSizeTick := A_TickCount
          ;Calculate the downloadspeed
            Speed := Round((CurrentSize/1024-LastSize/1024)/((CurrentSizeTick-LastSizeTick)/1000)) . &quot; Kb/s&quot;
          ;Save the current filesize and tick for the next time
            LastSizeTick := CurrentSizeTick
            LastSize := FileOpen(SaveFileAs, &quot;r&quot;).Length
          ;Calculate percent done
            PercentDone := Round(CurrentSize/FinalSize*100)
          ;Update the ProgressBar
            Progress, %PercentDone%, %PercentDone%`% Done, Downloading...  (%Speed%), Downloading %SaveFileAs% (%PercentDone%`%)
      Return
}
</code></pre></div><p>Я просто только Яндексом искал... <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></description>
			<author><![CDATA[null@example.com (senyaonis)]]></author>
			<pubDate>Sun, 05 Jun 2016 03:17:19 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=104712#p104712</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прогресс загрузки файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=104675#p104675</link>
			<description><![CDATA[<p><a href="http://cse.google.com/cse?cref=https%3A%2F%2Fcse.google.com%2Ftools%2Fmakecse%3Furl%3Dhttps%253A%252F%252Fwww.autohotkey.com%252F&amp;ie=UTF-8&amp;hl=&amp;cx=010629462602499112316%3Aywoq_rufgic&amp;q=UrlDownloadToFile+progress&amp;sa=Search&amp;siteurl=www.autohotkey.com%2F&amp;ref=&amp;ss=9333j12115149j19#gsc.tab=0&amp;gsc.q=UrlDownloadToFile%20progress&amp;gsc.page=1">http://cse.google.com/cse?cref=https%3A … gsc.page=1</a></p>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Sat, 04 Jun 2016 11:25:48 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=104675#p104675</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Прогресс загрузки файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=104660#p104660</link>
			<description><![CDATA[<p>Возможно сделать прогресс бар для UrlDownloadToFile?</p>]]></description>
			<author><![CDATA[null@example.com (senyaonis)]]></author>
			<pubDate>Fri, 03 Jun 2016 19:18:14 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=104660#p104660</guid>
		</item>
	</channel>
</rss>
