<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Загрузка файла из интернета]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=15214&amp;type=atom" />
	<updated>2023-04-19T09:32:42Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=15214</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Загрузка файла из интернета]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=157700#p157700" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>UrlToFile := &quot;https:?&quot;
SaveFileAs := A_ScriptDir . &quot;\1.Расширения файла&quot;
Overwrite := True
If (FileExist(SaveFileAs)) {
    If (Overwrite)
        FileDelete, %SaveFileAs%
    Else
        Return
}

WinHttpObj := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
WinHttpObj.Open(&quot;GET&quot;, UrlToFile)
WinHttpObj.SetRequestHeader(&quot;Cookie&quot;,&quot;bb_ssl=1; bb_session=?&quot;)
WinHttpObj.Send()
ADODBObj := ComObjCreate(&quot;ADODB.Stream&quot;)
ADODBObj.Type := 1
ADODBObj.Open()
ADODBObj.Write(WinHttpObj.ResponseBody)
ADODBObj.SaveToFile(SaveFileAs, Overwrite ? 2:1)
ADODBObj.Close()</code></pre></div>]]></content>
			<author>
				<name><![CDATA[EV]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40256</uri>
			</author>
			<updated>2023-04-19T09:32:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=157700#p157700</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Загрузка файла из интернета]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=157697#p157697" />
			<content type="html"><![CDATA[<p>Если вы можете скачать файл через интернет эксплорер, то и UrlDownloadToFile теоретически должен работать (хотя не факт), так как autohotkey использует &quot;AutoHotkey&quot; как user-agent:<br /><a href="https://github.com/AutoHotkey/AutoHotkey/blob/v1.1/source/script_autoit.cpp#L1024">https://github.com/AutoHotkey/AutoHotke … .cpp#L1024</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2023-04-18T22:38:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=157697#p157697</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Загрузка файла из интернета]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=157696#p157696" />
			<content type="html"><![CDATA[<p>У меня скачивается HTML-страница с расширением PDF, внутри которой есть ссылка на PDF:<br /></p><div class="codebox"><pre><code>https:\/\/psv4.userapi.com\/c235131\/u3260116\/docs\/d8\/36b926714245\/Beregis_shpionov_Sheynin_L.pdf?extra=ZWlUw7eqI5e-eFzWz71Ghbm7JHM-_SP_RuAu1JGs05AT0nWK25CcsQU_nGt19y7F2dAlimWVBWiath91EAHlB18cnRnn0zYaP_fuQgi_TW-vmVSK8TFDERANTbrdIrsX6E5c2jJE_ZM</code></pre></div><p>Но сам файл не скачивается. Значит, UrlDownloadToFile не подходит для подобной загрузки?</p>]]></content>
			<author>
				<name><![CDATA[john_dease]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42972</uri>
			</author>
			<updated>2023-04-18T21:39:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=157696#p157696</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Загрузка файла из интернета]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=157695#p157695" />
			<content type="html"><![CDATA[<p>Всё прекрасно скачивается.<br />Может cкачивается не то, что вы хотели...<br />А почему такое происходит - додумайтесь сами. <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2023-04-18T21:31:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=157695#p157695</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Загрузка файла из интернета]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=157694#p157694" />
			<content type="html"><![CDATA[<p>По какой причине не скачивается файл через UrlDownloadToFile, хотя в браузере открывается?</p><div class="codebox"><pre><code>UrlDownloadToFile, https://vk.com/doc3260116_654218993?hash=9uXtHHpoQoROguesZgflOXaYZzBVGGFEygnUkQSzPPD, %a_scriptdir%\1111111111111.pdf</code></pre></div>]]></content>
			<author>
				<name><![CDATA[john_dease]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42972</uri>
			</author>
			<updated>2023-04-18T21:09:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=157694#p157694</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Загрузка файла из интернета]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138183#p138183" />
			<content type="html"><![CDATA[<p>С интернета.<br />Кстати автохоткивская команда urldownloadtofile использует эту же константу (INTERNET_FLAG_RELOAD) + INTERNET_FLAG_NO_CACHE_WRITE через wininet.<br /></p><div class="quotebox"><cite>svoboden пишет:</cite><blockquote><p>И почему в Installer.ahk не использовать urldownloadtofile тогда, если отличия не большие</p></blockquote></div><p>Как же небольшие -&nbsp; или каждый раз заново скачивается или берется с кеша.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-03-01T13:44:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138183#p138183</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Загрузка файла из интернета]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138181#p138181" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>В UrlDownloadtoFile в отличии от URLDownloadToCacheFile не удастся прописать  BINDF_GETNEWESTVERSION.</p></blockquote></div><p>А откуда тут эта константа взялась?<br /></p><div class="codebox"><pre><code>HRESULT URLDownloadToCacheFile(
  _In_       LPUNKNOWN           lpUnkcaller,
  _In_       LPCSTR              szURL,
  _Out_      LPTSTR              szFileName,
  _In_       DWORD               cchFileName,
  _Reserved_ DWORD               dwReserved,
  _In_opt_   IBindStatusCallback *pBSC
);</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2020-03-01T10:58:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138181#p138181</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Загрузка файла из интернета]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138180#p138180" />
			<content type="html"><![CDATA[<p>Значит URLDownloadToCacheFile лучше использовать? А насколько правильна функция выше, т.к. много функций из того файла пропущены. И почему в Installer.ahk не использовать urldownloadtofile тогда, если отличия не большие.</p>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2020-03-01T10:46:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138180#p138180</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Загрузка файла из интернета]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138177#p138177" />
			<content type="html"><![CDATA[<p>В UrlDownloadtoFile в отличии от URLDownloadToCacheFile не удастся прописать&nbsp; BINDF_GETNEWESTVERSION.<br /></p><div class="quotebox"><blockquote><p>DllCall(&quot;urlmon\URLDownloadToCacheFile&quot;, &quot;ptr&quot;, 0, &quot;str&quot;, url, &quot;str&quot;, tn, &quot;uint&quot;, 260, &quot;uint&quot;, <strong>0x10</strong>, &quot;ptr*&quot;, &amp;vt)</p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-03-01T10:36:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138177#p138177</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Загрузка файла из интернета]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=138176#p138176" />
			<content type="html"><![CDATA[<p>Удалось загрузить файл из гугл диска, используя функцию из файла Installer.ahk (оно же файл установки автохоткея):</p><div class="codebox"><pre><code>url  := &quot;https://drive.google.com/uc?id=свой id&amp;authuser=0&amp;export=download&quot; ; свой запрос (в примере загружает exe) для разных типов файлов расширения разные.
file := &quot;путь загрузки файла/Backup.exe&quot;

Download(url, file)

Download(url, file)
{
    static vt
    if !VarSetCapacity(vt)
    {
        VarSetCapacity(vt, A_PtrSize*11), nPar := &quot;31132253353&quot;
        Loop Parse, nPar
            NumPut(RegisterCallback(&quot;DL_Progress&quot;, &quot;F&quot;, A_LoopField, A_Index-1), vt, A_PtrSize*(A_Index-1))
    }
    global _cu
    SplitPath file, dFile
    SysGet m, MonitorWorkArea, 1
    scale := A_ScreenDPI ? A_ScreenDPI/96 : 1, y := mBottom-52*scale-2, x := mRight-330*scale-2
    , VarSetCapacity(_cu, 100), VarSetCapacity(tn, 520)
    , DllCall(&quot;shlwapi\PathCompactPathEx&quot;, &quot;str&quot;, _cu, &quot;str&quot;, url, &quot;uint&quot;, 50, &quot;uint&quot;, 0)
    Progress Hide CWFAFAF7 CT000020 CB445566 x%x% y%y% w330 h52 B1 FS8 WM700 WS700 FM8 ZH12 ZY3 C11,, %_cu%, AutoHotkeyProgress, Tahoma
    if (0 = DllCall(&quot;urlmon\URLDownloadToCacheFile&quot;, &quot;ptr&quot;, 0, &quot;str&quot;, url, &quot;str&quot;, tn, &quot;uint&quot;, 260, &quot;uint&quot;, 0x10, &quot;ptr*&quot;, &amp;vt))
        FileCopy %tn%, %file%, 1
    else
        ErrorLevel := 1
    Progress Off
    return !ErrorLevel
}
DL_Progress( pthis, nP=0, nPMax=0, nSC=0, pST=0 )
{
    global _cu
    if A_EventInfo = 6
    {
        Progress Show
        Progress % P := 100*nP//nPMax, % &quot;Downloading:     &quot; Round(np/1024,1) &quot; KB / &quot; Round(npmax/1024) &quot; KB    [ &quot; P &quot;`% ]&quot;, %_cu%
    }
    return 0
}</code></pre></div><p>Вопрос такой: &quot;нормальный ли это метод загрузки файлов из интернета? Или же лучше использовать UrlDownloadtoFile?<br />Вариант с wget и подобными утилитами не очень (часто выдавало ошибки). И как можно улучшить эту функции, т.к. много функций из файла мне непонятны. И вообще работает ли у вас этот способ загрузки файла?</p>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2020-03-01T10:17:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=138176#p138176</id>
		</entry>
</feed>
