<?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=14168&amp;type=atom" />
	<updated>2018-09-17T13:51:22Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=14168</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скриншот неактивного окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=128749#p128749" />
			<content type="html"><![CDATA[<p><strong>stealzy</strong>, вот рабочий пример. Подмечу что если свернуть окно то скриншоты буду черными или будет только заголовок окна. Поэтому нужно перевести в оконный режим и сделать просто неактивным.<br /></p><div class="codebox"><pre><code>
hwnd    := WinExist(&quot;GTA:SA:MP&quot;)
pToken  := Gdip_Startup()
pBitmap := Gdip_BitmapFromHWND(hwnd)

SaveBitmapToFile(pBitmap, &quot;Screenshot.png&quot;) ; .jpg или другой нужный формат.

Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
</code></pre></div><p>Для работы нужно иметь инклуд Gdip_All - <a href="https://github.com/Drugoy/Autohotkey-scripts-.ahk/blob/master/Libraries/Gdip_All.ahk">https://github.com/Drugoy/Autohotkey-sc … ip_All.ahk</a></p><p>По сколько там нет функции SaveBitmapToFile, отправлю здесь.<br /></p><div class="codebox"><pre><code>
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
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[slavafedora]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34221</uri>
			</author>
			<updated>2018-09-17T13:51:22Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=128749#p128749</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скриншот неактивного окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=128726#p128726" />
			<content type="html"><![CDATA[<p><strong>slavafedora</strong>, держите нас в курсе.</p>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2018-09-16T16:52:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=128726#p128726</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скриншот неактивного окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=128723#p128723" />
			<content type="html"><![CDATA[<p>Все, получилось самостоятельно реализовать. Если кому то будет нужно отпишитесь скину.<br />Тема не актуальна.</p>]]></content>
			<author>
				<name><![CDATA[slavafedora]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34221</uri>
			</author>
			<updated>2018-09-16T15:12:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=128723#p128723</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Скриншот неактивного окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=128721#p128721" />
			<content type="html"><![CDATA[<p><a href="http://forum.script-coding.com/viewtopic.php?id=8574">http://forum.script-coding.com/viewtopic.php?id=8574</a><br />Способ точно такой же, но не в виде BitMap в виде в картинки.</p>]]></content>
			<author>
				<name><![CDATA[slavafedora]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34221</uri>
			</author>
			<updated>2018-09-16T14:39:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=128721#p128721</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Скриншот неактивного окна]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=128699#p128699" />
			<content type="html"><![CDATA[<p>Добрый день форумчане, видел подобные темы но так и не нашел точно ответа как получить скриншот неактивного окна и сохранить его файлом.<br />У меня получился примерно вот такой код, но как правильно использовать его и не знаю. Может кто-то подскажет?<br /></p><div class="codebox"><pre><code>
WinGet, task_id, ID, GTA:SA:MP
DllCall(&quot;PrintWindow&quot;, UInt, task_id, UInt, hdc_buffer, UInt,0)
</code></pre></div><p>Я как понял переменная hdc_buffer будет содержать всю информацию, но что-то ничего так и не вышло у меня.</p>]]></content>
			<author>
				<name><![CDATA[slavafedora]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34221</uri>
			</author>
			<updated>2018-09-15T18:34:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=128699#p128699</id>
		</entry>
</feed>
