<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Переполнение Rum, Bitmap]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=15575&amp;type=atom" />
	<updated>2021-12-01T19:32:13Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=15575</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переполнение Rum, Bitmap]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=150881#p150881" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Turuan]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41011</uri>
			</author>
			<updated>2021-12-01T19:32:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=150881#p150881</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переполнение Rum, Bitmap]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141474#p141474" />
			<content type="html"><![CDATA[<p><strong>stealzy</strong><br />Попробовал.<br />Прекрасно работает память не засоряется.<br />Огромное спасибо.</p>]]></content>
			<author>
				<name><![CDATA[Turuan]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41011</uri>
			</author>
			<updated>2020-08-05T17:22:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141474#p141474</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переполнение Rum, Bitmap]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141472#p141472" />
			<content type="html"><![CDATA[<p><a href="http://forum.script-coding.com/viewtopic.php?pid=140026#p140026">Попробуйте</a>.</p>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2020-08-05T16:16:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141472#p141472</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Переполнение Rum, Bitmap]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=141471#p141471" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Turuan]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41011</uri>
			</author>
			<updated>2020-08-05T15:33:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=141471#p141471</id>
		</entry>
</feed>
