<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Поиск изображения с вариациями при помощи GDI при включённом Aero]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13722&amp;type=atom" />
	<updated>2018-05-19T21:31:31Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=13722</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск изображения с вариациями при помощи GDI при включённом Aero]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125473#p125473" />
			<content type="html"><![CDATA[<p><a href="http://forum.script-coding.com/viewtopic.php?id=12938">http://forum.script-coding.com/viewtopic.php?id=12938</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2018-05-19T21:31:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125473#p125473</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Поиск изображения с вариациями при помощи GDI при включённом Aero]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125471#p125471" />
			<content type="html"><![CDATA[<p>Приветствую всех зашедших в эту тему! Ситуация следующая:&nbsp; Как многим известно функции PixelSearch и ImageSearch в AHK работают крайне медленно при включенном Aero. Появилась необходимость как-то ускорить этот процесс и я обратил внимание на GDI+. Поиск изображения оказался достаточно простым даже для новичка вроде меня, но я столкнулся с одной проблемой… В отличие от нативных AHK функций, GDI+ не умеет искать пиксели с вариацией, так же удобно как это делает AHK. Немного порыскав, по офф. форуму я наткнулся, на пользователя предложившего решение этого вопроса. Проблема в том, что в этом самом решении используется DLL написанная на C или C++. Так как я совсем не разбираюсь в вопросах компилирования DLL и с английским не очень дружу, хотел бы попросить помощи здесь. Уважаемые, кто-нибудь может скомпилировать эту DLL? Код самой AHK функции и код для DLL прикладываю. Заранее спасибо!</p><p>Dll исходник<br /></p><div class="codebox"><pre><code> extern &quot;C&quot;
{
	__declspec(dllexport) int PixelSearch(unsigned char * Bitmap, int Color, int x1, int y1, int x2, int y2, int Stride, int * x, int * y, int v)
	{
		int tx, ty, o, R, G, B;
		int R1 = (Color &amp; 0x00ff0000) &gt;&gt; 16;
		int G1 = (Color &amp; 0x0000ff00) &gt;&gt; 8;
		int B1 = Color &amp; 0x000000ff;
		tx = x1;
		for (int w1 = 0; w1 &lt; x2; ++w1)
		{
			ty = y1;
			for (int h1 = 0; h1 &lt; y2; ++h1)
			{
				o = (4*tx)+(ty*Stride);
				R = Bitmap[2+o];
				G = Bitmap[1+o];
				B = Bitmap[o];
				if ((R == R1) &amp;&amp; (G == G1) &amp;&amp; (B == B1))
				{
						x[0] = tx; y[0] = ty;
						return false;
				}
				ty++;
			}
			tx++;
		}
		x[0] = 0; y[0] = 0;
		return true;
	}
}
</code></pre></div><p>Функция AHK<br /></p><div class="codebox"><pre><code>#SingleInstance, Force 
#NoEnv

SetBatchLines, -1
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen

#Include Gdip.ahk

MCode(ByRef code, hex) { ; allocate memory and write Machine Code there
   VarSetCapacity(code,StrLen(hex)//2)
   Loop % StrLen(hex)//2
      NumPut(&quot;0x&quot; . SubStr(hex,2*A_Index-1,2), code, A_Index-1, &quot;Char&quot;)
}

Gdip_PixelSearch(ByRef x, ByRef y, x1, y1, x2, y2, Color, Variation)
{
MCode(PixelSearch,
(LTrim Join
&quot;83EC0C8B44241453558BE88BC825FF000000C1FD10C1F90881E5FF00000081E1
 FF000000837C2428008944240C8B4424205657896C2418894C241089442424C7
 442428000000007E758B5424388B5C24348B7C242C33F685DB7E508B4424248B
 CF0FAFCA8D04818B4C242003C88D4900BB020000000FB61C0B3BDD751C8B5C24
 200FB65C18013B5C241075090FB6193B5C2414744A8B6C24188B5C2434464703
 C203CA3BF37CC98B7C242C8B442428FF44242440894424283B4424307C978B54
 243C8B4424405F5EC702000000005DC70000000000B8010000005B83C40CC38B
 4424248B54243C8B4C2440890289395F5E5D33C05B83C40CC3&quot;
))
pBitmap := Gdip_BitmapFromScreen(), Gdip_GetDimensions(pBitmap, w, h)
E1 := Gdip_LockBits(pBitmap, 0, 0, w, h, Stride, Scan0, BitmapData)
e := DllCall(&amp;PixelSearch,&quot;uint&quot;,scan0,&quot;int&quot;,color,&quot;int&quot;,x1,&quot;int&quot;,y1,&quot;int&quot;,x2,&quot;int&quot;,y2,&quot;int&quot;,stride,&quot;int*&quot;,x,&quot;int*&quot;,y,&quot;uint&quot;,v,&quot;cdecl uint&quot;)
Gdip_UnlockBits(pBitmap, BitmapData)
Gdip_DisposeImage(pBitmap)
return e
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Kamui_Roar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39271</uri>
			</author>
			<updated>2018-05-19T21:05:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125471#p125471</id>
		</entry>
</feed>
