<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Как сделать скриншот (PrintWindow) ?]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=8574</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=8574&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Как сделать скриншот (PrintWindow) ?».]]></description>
		<lastBuildDate>Wed, 04 Sep 2013 16:52:24 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Как сделать скриншот (PrintWindow) ?]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=75209#p75209</link>
			<description><![CDATA[<div class="codebox"><pre><code>var := 4293587451
PrevFormat := A_FormatInteger
SetFormat, IntegerFast, H
MsgBox, % var
SetFormat, IntegerFast, % PrevFormat
</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 04 Sep 2013 16:52:24 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=75209#p75209</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как сделать скриншот (PrintWindow) ?]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=75187#p75187</link>
			<description><![CDATA[<div class="codebox"><pre><code>buff := Gdip_GetPixel(pBitmap, x, y)
</code></pre></div><p>получается типа такое</p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><p><span class="postimg"><img src="http://f4.s.qip.ru/AUIOPQiE.png" alt="http://f4.s.qip.ru/AUIOPQiE.png" /></span></p></div></div><p>как его конвернтуть в типа </p><div class="codebox"><pre><code>0xEDE0D4</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Hydrogenium)]]></author>
			<pubDate>Wed, 04 Sep 2013 02:11:38 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=75187#p75187</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как сделать скриншот (PrintWindow) ?]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=75004#p75004</link>
			<description><![CDATA[<p><strong>teadrinker</strong>, спасиб, я попозже разберу</p>]]></description>
			<author><![CDATA[null@example.com (Hydrogenium)]]></author>
			<pubDate>Wed, 28 Aug 2013 05:05:27 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=75004#p75004</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как сделать скриншот (PrintWindow) ?]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=74582#p74582</link>
			<description><![CDATA[<div class="codebox"><pre><code>hwnd := WinExist(&quot;A&quot;)   ; указать нужный хэндл
pToken := Gdip_Startup()
MsgBox, % pBitmap := Gdip_BitmapFromHWND(hwnd)   ; адрес Bitmap

; здесь нужные действия с Bitmap
; для поиска пикселя можно воспользоваться Gdip_GetPixel(pBitmap, x, y)

Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
return


Gdip_Startup()
{
   if !DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, &quot;gdiplus&quot;, &quot;ptr&quot;)
      DllCall(&quot;LoadLibrary&quot;, &quot;str&quot;, &quot;gdiplus&quot;)
   VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1)
   DllCall(&quot;gdiplus\GdiplusStartup&quot;, &quot;uptr*&quot;, pToken, &quot;ptr&quot;, &amp;si, &quot;ptr&quot;, 0)
   return pToken
}

Gdip_BitmapFromHWND(hwnd)
{
   WinGetPos,,, Width, Height, ahk_id %hwnd%
   hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
   PrintWindow(hwnd, hdc)
   pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
   SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
   return pBitmap
}

CreateDIBSection(w, h, hdc=&quot;&quot;, bpp=32, ByRef ppvBits=0)
{
   hdc2 := hdc ? hdc : GetDC()
   VarSetCapacity(bi, 40, 0)
   NumPut(w, bi, 4, &quot;uint&quot;), NumPut(h, bi, 8, &quot;uint&quot;), NumPut(40, bi, 0, &quot;uint&quot;)
      , NumPut(1, bi, 12, &quot;ushort&quot;), NumPut(0, bi, 16), NumPut(bpp, bi, 14, &quot;ushort&quot;)
   hbm := DllCall(&quot;CreateDIBSection&quot;, &quot;ptr&quot; , hdc2, &quot;ptr&quot; , &amp;bi, &quot;uint&quot; , 0, &quot;ptr*&quot;, ppvBits, &quot;ptr&quot; , 0, &quot;uint&quot; , 0, &quot;ptr&quot;)

   if !hdc
      ReleaseDC(hdc2)
   return hbm
}

GetDC(hwnd=0)
{
   return DllCall(&quot;GetDC&quot;, &quot;ptr&quot;, hwnd, &quot;ptr&quot;)
}

ReleaseDC(hdc, hwnd=0)
{
   return DllCall(&quot;ReleaseDC&quot;, &quot;ptr&quot;, hwnd, &quot;ptr&quot;, hdc)
}

CreateCompatibleDC(hdc=0)
{
   return DllCall(&quot;CreateCompatibleDC&quot;, &quot;ptr&quot;, hdc, &quot;ptr&quot;)
}

SelectObject(hdc, hgdiobj)
{
   return DllCall(&quot;SelectObject&quot;, &quot;ptr&quot;, hdc, &quot;ptr&quot;, hgdiobj, &quot;ptr&quot;)
}

PrintWindow(hwnd, hdc, Flags=0)
{
   return DllCall(&quot;PrintWindow&quot;, &quot;ptr&quot;, hwnd, &quot;ptr&quot;, hdc, &quot;uint&quot;, Flags)
}

Gdip_CreateBitmapFromHBITMAP(hBitmap, Palette=0)
{
   DllCall(&quot;gdiplus\GdipCreateBitmapFromHBITMAP&quot;, &quot;ptr&quot;, hBitmap, &quot;ptr&quot;, Palette, &quot;ptr*&quot;, pBitmap)
   return pBitmap
}

Gdip_GetPixel(pBitmap, x, y)
{
   DllCall(&quot;gdiplus\GdipBitmapGetPixel&quot;, &quot;ptr&quot;, pBitmap, &quot;int&quot;, x, &quot;int&quot;, y, &quot;uint*&quot;, ARGB)
   return ARGB
}

DeleteObject(hObject)
{
   return DllCall(&quot;DeleteObject&quot;, &quot;ptr&quot;, hObject)
}

DeleteDC(hdc)
{
   return DllCall(&quot;DeleteDC&quot;, &quot;ptr&quot;, hdc)
}

Gdip_DisposeImage(pBitmap)
{
   return DllCall(&quot;gdiplus\GdipDisposeImage&quot;, &quot;ptr&quot;, pBitmap)
}

Gdip_Shutdown(pToken)
{
   DllCall(&quot;gdiplus\GdiplusShutdown&quot;, &quot;uptr&quot;, pToken)
   if hModule := DllCall(&quot;GetModuleHandle&quot;, &quot;str&quot;, &quot;gdiplus&quot;, &quot;ptr&quot;)
      DllCall(&quot;FreeLibrary&quot;, &quot;ptr&quot;, hModule)
   return 0
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 15 Aug 2013 18:26:47 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=74582#p74582</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как сделать скриншот (PrintWindow) ?]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=74556#p74556</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>А в каком виде ты хочешь получить скриншот? В виде bitmap, или в виде картинки в окне, или в виде файла? И как ты хочешь искать там пиксель?</p></blockquote></div><p>в виде bitmap</p>]]></description>
			<author><![CDATA[null@example.com (Hydrogenium)]]></author>
			<pubDate>Wed, 14 Aug 2013 23:54:46 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=74556#p74556</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как сделать скриншот (PrintWindow) ?]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=74555#p74555</link>
			<description><![CDATA[<p>А в каком виде ты хочешь получить скриншот? В виде bitmap, или в виде картинки в окне, или в виде файла? И как ты хочешь искать там пиксель?</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 14 Aug 2013 22:59:56 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=74555#p74555</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Как сделать скриншот (PrintWindow) ?]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=74550#p74550</link>
			<description><![CDATA[<p>Вообщем есть такая API PrintWindow (делает скрин окна, даже если оно перекрыто другими окнами)<br />Мне нужно сделать подобный скрин и найти там пиксель</p><p>Подскажите как реализовать эту здачу</p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><div class="codebox"><pre><code>
   
F11::
    myFunc()
Return

myFunc()
{   
  h := GetWin
  if h &lt;&gt; 0
    BitmapFromHWND(h)
}

GetWin()
{
    Win := &quot;Калькулятор&quot;
    
    Res := 0
    
    WinGet, id, list
    Loop, %id%
    {
        this_id := id%A_Index%
        WinGetTitle, this_title, ahk_id %this_id% 
        
        if this_title = Win
        {
            Res := this_id 
            break
        }
    }
    
    Return Res
}

BitmapFromHWND(hwnd)
{
    WinGetPos,,, Width, Height, ahk_id %hwnd%
    hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
    PrintWindow(hwnd, hdc)
    pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
    SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
    
    Return pBitmap
}

PrintWindow(hwnd, hdc, Flags=0)
{
    return DllCall(&quot;PrintWindow&quot;, &quot;uint&quot;, hwnd, &quot;uint&quot;, hdc, &quot;uint&quot;, Flags)
}

</code></pre></div></div></div><p>Это мой код на основе <a href="http://www.autohotkey.net/~tic/Gdip.ahk">http://www.autohotkey.net/~tic/Gdip.ahk</a></p>]]></description>
			<author><![CDATA[null@example.com (Hydrogenium)]]></author>
			<pubDate>Wed, 14 Aug 2013 21:31:41 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=74550#p74550</guid>
		</item>
	</channel>
</rss>
