<?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=17292</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=17292&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Помогите сделать скриншот».]]></description>
		<lastBuildDate>Mon, 08 Aug 2022 07:37:10 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Помогите сделать скриншот]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154254#p154254</link>
			<description><![CDATA[<p><strong>alex16uk</strong><br />Для этого вам нужно получать текущую дату, а далее указывать в строчке за место имени &quot;screenshot.png&quot; - переменную, которая будет содержать дату:<br /></p><div class="codebox"><pre><code>screenshot:=(A_ScriptDir . &quot;\screenshot.png&quot;)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Clannad5)]]></author>
			<pubDate>Mon, 08 Aug 2022 07:37:10 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154254#p154254</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Помогите сделать скриншот]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154239#p154239</link>
			<description><![CDATA[<p><strong>Clannad5</strong> А как сделать что бы он сохранял скриншот где в название время скрина а не screenshot?</p>]]></description>
			<author><![CDATA[null@example.com (alex16uk)]]></author>
			<pubDate>Sat, 06 Aug 2022 19:30:11 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154239#p154239</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Помогите сделать скриншот]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154232#p154232</link>
			<description><![CDATA[<p><strong>alex16uk</strong><br /></p><div class="codebox"><pre><code>screenshot:=(A_ScriptDir . &quot;\screenshot.png&quot;)
SaveScreenshotToFile(0, 0, A_ScreenWidth, A_ScreenHeight, screenshot)

SaveScreenshotToFile(x, y, w, h, filePath)
{
	hBitmap := GetHBitmapFromScreen(x, y, w, h)
	gdip := new GDIplus
	pBitmap := gdip.BitmapFromHBitmap(hBitmap)
	DllCall(&quot;DeleteObject&quot;, Ptr, hBitmap)
	gdip.SaveBitmapToFile(pBitmap, filePath)
	gdip.DisposeImage(pBitmap)
}

GetHBitmapFromScreen(x, y, w, h)
{
	hDC := DllCall(&quot;GetDC&quot;, Ptr, 0, Ptr)
	hBM := DllCall(&quot;CreateCompatibleBitmap&quot;, Ptr, hDC, Int, w, Int, h, Ptr)
	pDC := DllCall(&quot;CreateCompatibleDC&quot;, Ptr, hDC, Ptr)
	oBM := DllCall(&quot;SelectObject&quot;, Ptr, pDC, Ptr, hBM, Ptr)
	DllCall(&quot;BitBlt&quot;, Ptr, pDC, Int, 0, Int, 0, Int, w, Int, h, Ptr, hDC, Int, x, Int, y, UInt, 0x00CC0020)
	DllCall(&quot;SelectObject&quot;, Ptr, pDC, Ptr, oBM)
	DllCall(&quot;DeleteDC&quot;, Ptr, pDC)
	DllCall(&quot;ReleaseDC&quot;, Ptr, 0, Ptr, hDC)
	Return hBM
}

class GDIplus   {
	__New()  {
		if !DllCall(&quot;GetModuleHandle&quot;, Str, &quot;gdiplus&quot;, Ptr)
			DllCall(&quot;LoadLibrary&quot;, Str, &quot;gdiplus&quot;)
		VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
		DllCall(&quot;gdiplus\GdiplusStartup&quot;, PtrP, pToken, Ptr, &amp;si, Ptr, 0)
		this.token := pToken
	}
	__Delete()  {
		DllCall(&quot;gdiplus\GdiplusShutdown&quot;, Ptr, this.token)
		if hModule := DllCall(&quot;GetModuleHandle&quot;, Str, &quot;gdiplus&quot;, Ptr)
			DllCall(&quot;FreeLibrary&quot;, Ptr, hModule)
	}
	BitmapFromHBitmap(hBitmap, Palette := 0)  {
		DllCall(&quot;gdiplus\GdipCreateBitmapFromHBITMAP&quot;, Ptr, hBitmap, Ptr, Palette, PtrP, pBitmap)
		return pBitmap
	}
	SaveBitmapToFile(pBitmap, sOutput, Quality=75)  {
		SplitPath, sOutput,,, Extension
		if Extension not in BMP,DIB,RLE,JPG,JPEG,JPE,JFIF,GIF,TIF,TIFF,PNG
			return -1
		DllCall(&quot;gdiplus\GdipGetImageEncodersSize&quot;, UIntP, nCount, UIntP, nSize)
		VarSetCapacity(ci, nSize)
		DllCall(&quot;gdiplus\GdipGetImageEncoders&quot;, UInt, nCount, UInt, nSize, Ptr, &amp;ci)
		if !(nCount &amp;&amp; nSize)
			return -2
		Loop, % nCount  {
			sString := StrGet(NumGet(ci, (idx := (48+7*A_PtrSize)*(A_Index-1))+32+3*A_PtrSize), &quot;UTF-16&quot;)
			if !InStr(sString, &quot;*.&quot; Extension)
				continue
			pCodec := &amp;ci+idx
			break
		}
		if !pCodec
			return -3
		if RegExMatch(Extension, &quot;i)^J(PG|PEG|PE|FIF)$&quot;) &amp;&amp; Quality != 75  {
			DllCall(&quot;gdiplus\GdipGetEncoderParameterListSize&quot;, Ptr, pBitmap, Ptr, pCodec, UintP, nSize)
			VarSetCapacity(EncoderParameters, nSize, 0)
			DllCall(&quot;gdiplus\GdipGetEncoderParameterList&quot;, Ptr, pBitmap, Ptr, pCodec, UInt, nSize, Ptr, &amp;EncoderParameters)
			Loop, % NumGet(EncoderParameters, &quot;UInt&quot;)  {
				elem := (24+A_PtrSize)*(A_Index-1) + 4 + (pad := A_PtrSize = 8 ? 4 : 0)
				if (NumGet(EncoderParameters, elem+16, &quot;UInt&quot;) = 1) &amp;&amp; (NumGet(EncoderParameters, elem+20, &quot;UInt&quot;) = 6)  {
					p := elem+&amp;EncoderParameters-pad-4
					NumPut(Quality, NumGet(NumPut(4, NumPut(1, p+0)+20, &quot;UInt&quot;)), &quot;UInt&quot;)
					break
				}
			}
		}
		if A_IsUnicode
			pOutput := &amp;sOutput
		else  {
			VarSetCapacity(wOutput, StrPut(sOutput, &quot;UTF-16&quot;)*2, 0)
			StrPut(sOutput, &amp;wOutput, &quot;UTF-16&quot;)
			pOutput := &amp;wOutput
		}
		E := DllCall(&quot;gdiplus\GdipSaveImageToFile&quot;, Ptr, pBitmap, Ptr, pOutput, Ptr, pCodec, UInt, p ? p : 0)
		return E ? -5 : 0
	}
	DisposeImage(pBitmap)  {
		return DllCall(&quot;gdiplus\GdipDisposeImage&quot;, Ptr, pBitmap)
	}
}
Return</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Clannad5)]]></author>
			<pubDate>Sat, 06 Aug 2022 01:19:14 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154232#p154232</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Помогите сделать скриншот]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154224#p154224</link>
			<description><![CDATA[<p><strong>alex16uk</strong>, уже лучше. Ещё есть правило: <a href="https://forum.script-coding.com/rules.html#3.11.">одна тема — один вопрос</a>. Так что выбирайте основной, для остальных создавайте новые темы, тем более, что вопросы никак не связаны.<br /></p><div class="quotebox"><cite>alex16uk пишет:</cite><blockquote><p>Мне нужно что бы AHK сохранило скриншот с экрана и сохранил в папку</p></blockquote></div><p>Я бы советовал воспользоваться поиском по форуму. Также у нас есть Коммерческий раздел, заказы лучше размещать там.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 05 Aug 2022 12:25:53 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154224#p154224</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Помогите сделать скриншот]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154223#p154223</link>
			<description><![CDATA[<p><strong>Foma</strong>, what the fuck?<br /><strong>alex16uk</strong>, добро пожаловать на форум! Ознакомьтесь, пожалуйста, с <a href="https://forum.script-coding.com/misc.php?action=rules">Правилами</a>, отредактируйте свой пост. Обратите внимание на заглавные <a href="https://forum.script-coding.com/misc.php?action=rules#literacy">буквы</a> в начале и точки в конце предложений.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Fri, 05 Aug 2022 11:51:08 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154223#p154223</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Помогите сделать скриншот]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154222#p154222</link>
			<description><![CDATA[<p>...</p>]]></description>
			<author><![CDATA[null@example.com (Foma)]]></author>
			<pubDate>Fri, 05 Aug 2022 11:40:21 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154222#p154222</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Помогите сделать скриншот]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154221#p154221</link>
			<description><![CDATA[<p>Заранее спасибо.</p>]]></description>
			<author><![CDATA[null@example.com (alex16uk)]]></author>
			<pubDate>Fri, 05 Aug 2022 11:24:12 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154221#p154221</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Помогите сделать скриншот]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=154220#p154220</link>
			<description><![CDATA[<p>Мне нужно что бы AHK сохранило скриншот с экрана и сохранил в папку ( всего экрана без выбора зоны и подобного ).</p>]]></description>
			<author><![CDATA[null@example.com (alex16uk)]]></author>
			<pubDate>Fri, 05 Aug 2022 11:08:24 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=154220#p154220</guid>
		</item>
	</channel>
</rss>
