<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Переполнение Rum, Bitmap]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=15575</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=15575&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Переполнение Rum, Bitmap».]]></description>
		<lastBuildDate>Wed, 01 Dec 2021 19:32:13 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Переполнение Rum, Bitmap]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=150881#p150881</link>
			<description><![CDATA[<p><strong>stealzy</strong><br />Не помню почему я не отписался, но рас зашел сюда считаю должным. В моем примере функций была ошибка, правильный код я приведу ниже, этот код был взят из поиска и он кстати твой и был приведен примером&nbsp; для кого то, это метод в моем примере(взятый из твоего поста) работает быстро и быстрее чем, то что ты дальше привел в пример. Ты просто забыл параметр 1 добавить, но было сложно разобраться когда ты только знакомишься с АХК. Исправь, это где то у себя в посте чтоб не травмировать людей ).</p><p>Было так:<br /></p><div class="codebox"><pre><code>WindowBitmap_Delete(hWnd, ByRef hDC, ByRef hBitmap) {
	DllCall(&quot;DeleteObject&quot;, Ptr, hBitmap)
	DllCall(&quot;DeleteDC&quot;, Ptr, hMemDC)
	DllCall(&quot;ReleaseDC&quot;, Ptr, hWnd, Ptr, hDC)
}
}</code></pre></div><p>Нужно так:<br /></p><div class="codebox"><pre><code>WindowBitmap_Delete(hWnd, ByRef hDC, ByRef hBitmap, hMemDC) {
	DllCall(&quot;DeleteObject&quot;, Ptr, hBitmap)
	DllCall(&quot;DeleteDC&quot;, Ptr, hMemDC)
	DllCall(&quot;ReleaseDC&quot;, Ptr, hWnd, Ptr, hDC)
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Turuan)]]></author>
			<pubDate>Wed, 01 Dec 2021 19:32:13 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=150881#p150881</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Переполнение Rum, Bitmap]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=141474#p141474</link>
			<description><![CDATA[<p><strong>stealzy</strong><br />Попробовал.<br />Прекрасно работает память не засоряется.<br />Огромное спасибо.</p>]]></description>
			<author><![CDATA[null@example.com (Turuan)]]></author>
			<pubDate>Wed, 05 Aug 2020 17:22:11 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=141474#p141474</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Переполнение Rum, Bitmap]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=141472#p141472</link>
			<description><![CDATA[<p><a href="http://forum.script-coding.com/viewtopic.php?pid=140026#p140026">Попробуйте</a>.</p>]]></description>
			<author><![CDATA[null@example.com (stealzy)]]></author>
			<pubDate>Wed, 05 Aug 2020 16:16:12 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=141472#p141472</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Переполнение Rum, Bitmap]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=141471#p141471</link>
			<description><![CDATA[<p>Пытаюсь разобратся с AHK.<br />Есть задача получать цвет пикселей в определенных координатах клиентского окна, сравнивать их с уже известными цветами.&nbsp; процесс цикличный.<br />PixelGetColor слишком медленный для моих задач.<br />Порывшись на форуме, нашел подходящие под мою задачу функции.<br />Все прекрасно работает, но очень быстро заканчивается оперативная память. Такое ощущение что в приведенном ниже скрипте функция WindowBitmap_Delete(hWnd, hDC, hBitmap) не чистит память. В чем может быть проблема ?<br /></p><div class="codebox"><pre><code>SetBatchLines -1
WinTitle = Безымянный – Блокнот
WinGet, hwnd, ID, %WinTitle%
x = 879
y = 153

loop 500
{
	hMemDC := WindowBitmap_Capture(hwnd, hDC, hBitmap) ; делаем снимок
	loop, 12
	{
		
		GetPixel(x, y)
		y += 72		
		; msgbox %Color%
	}
	WindowBitmap_Delete(hWnd, hDC, hBitmap) ; очищаем память
	sleep 10
}

WindowBitmap_PixelGetColor(hMemDC, x, y) {
	Return DllCall(&quot;GetPixel&quot;, Ptr, hMemDC, UInt, x, UInt, y)
}
WindowBitmap_Capture(hWnd, ByRef hDC, ByRef hBitmap) {
	WinGetPos,,, Width, Height, ahk_id %hWnd%
	hDC := DllCall(&quot;GetDC&quot;, Ptr, hWnd, Ptr)
	hMemDC := DllCall(&quot;CreateCompatibleDC&quot;, Ptr, hDC)
	hBitmap := DllCall(&quot;CreateCompatibleBitmap&quot;, Ptr, hDC, Int, Width, Int, Height, Ptr)
	DllCall(&quot;SelectObject&quot;, Ptr, hMemDC, Ptr, hBitmap)
	DllCall(&quot;PrintWindow&quot;, Ptr, hWnd, Ptr, hMemDC, UInt, 0) ; 0-50 ms depend on window size; GetPixel - 0.004 ms on each ( &gt; 8sec on FullHD display capture)
	Return hMemDC
}
WindowBitmap_Delete(hWnd, ByRef hDC, ByRef hBitmap) {
	DllCall(&quot;DeleteObject&quot;, Ptr, hBitmap)
	DllCall(&quot;DeleteDC&quot;, Ptr, hMemDC)
	DllCall(&quot;ReleaseDC&quot;, Ptr, hWnd, Ptr, hDC)
}
GetPixel(x, y) {
	global
	col := WindowBitmap_PixelGetColor(hMemDC, x, y)
	Color := (col = -1) ? &quot;Error&quot; : Format(&quot;{:#08x}&quot;,col)	
	Return Color
}

F8::Pause</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Turuan)]]></author>
			<pubDate>Wed, 05 Aug 2020 15:33:43 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=141471#p141471</guid>
		</item>
	</channel>
</rss>
