<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: PixelSearch]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=14495&amp;type=atom" />
	<updated>2022-06-14T06:15:58Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=14495</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: PixelSearch]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=153543#p153543" />
			<content type="html"><![CDATA[<p><strong>YanuK</strong>, если хотите оплатить работу, создавайте тему в коммерческом разделе. В любом случае не стоит писать в чужой теме.<br /></p><div class="quotebox"><cite>YanuK пишет:</cite><blockquote><p>могу пару сотней на кофе скинуть</p></blockquote></div><p>Честно говоря, не думаю, что кого-то парой сотен сможете заинтересовать.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-06-14T06:15:58Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=153543#p153543</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: PixelSearch]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=153542#p153542" />
			<content type="html"><![CDATA[<p>Добрый день всем, прошу вашей помощи в написании скрипта, у меня не навыков программирования, но поставили задачу. Задача, есть области экрана, сервис открывается на браузере IE: примерно 25 мигающих подобий кнопок, но не кнопки, они периодически рандомно, и необязательно все вместе меняют цвет (красный, синий, желтый). Нужно сделать скрипт, который считывал бы цвета и в зависимости от цвета воспроизводил бы разные сигналы. Буду приогромно благодарен, и могу пару сотней на кофе скинуть, но как курсовая задача. Винда 7. Спасибо заранее!</p>]]></content>
			<author>
				<name><![CDATA[YanuK]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=42592</uri>
			</author>
			<updated>2022-06-14T04:55:44Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=153542#p153542</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: PixelSearch]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=144469#p144469" />
			<content type="html"><![CDATA[<p><strong>SHOX</strong></p><p>F3 - указать окно и позицию пикселя.<br />F2 - получить в переменную &#039;pix&#039; цвет пикселя в окне.<br />F4 - для проверки.</p>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2021-01-02T14:15:42Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=144469#p144469</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: PixelSearch]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=144468#p144468" />
			<content type="html"><![CDATA[<p><strong>__Михаил__</strong><br />Здравствуйте.<br />Спасибо за ответ! Мне все ровно не понятно куда вставлять действие на найденный цвет пиксиля.&nbsp; Но я попробую разобраться.</p>]]></content>
			<author>
				<name><![CDATA[SHOX]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=39086</uri>
			</author>
			<updated>2021-01-02T06:52:10Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=144468#p144468</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: PixelSearch]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=144467#p144467" />
			<content type="html"><![CDATA[<p><strong>SHOX</strong></p><p>Да вроде всё просто, правда не у всех окон удаётся получить цвет пикселя.</p><div class="codebox"><pre><code>CoordMode, Mouse, Screen
CoordMode, Pixel, Screen

F3::	; Указать текущее окно и позицию.
MouseGetPos, X, Y, ID
WinGetTitle, App, Ahk_ID %ID%
Return

F4::	; Активация окна и перемещение мыши для теста.
WinActivate % App
Sleep, 100
MouseMove, % X, % Y
Return

F2::	; Получение цвета пикселя:
hWnd := WinExist(App)	; Получить идентификатор нужного окна.
p := WinGetP(hWnd)
xRel := X + p.ClientWin.x, yRel := Y + p.ClientWin.y
hDC := Window_CreateCapture(hWnd)
pix := GetPixel(hDC, xRel, yRel)
Window_DeleteWindowCapture(hWnd, hDC)

MsgBox % &quot;Цвет пикселя BGR: &quot; Format(&quot;{:#0X}&quot;, pix)
Return


Window_CreateCapture(hwnd) {
	Return DllCall(&quot;user32.dll\GetDCEx&quot;, &quot;UInt&quot;, hwnd, &quot;UInt&quot;, 0, &quot;UInt&quot;, 1|2)
}
GetPixel(hDC, x, y) {
	Return DllCall(&quot;gdi32.dll\GetPixel&quot;, &quot;UInt&quot;, hDC, &quot;Int&quot;, x, &quot;Int&quot;, y, &quot;UInt&quot;) ; colorBGR
}
Window_DeleteWindowCapture(hwnd, hDC) {
	DllCall(&quot;user32.dll\ReleaseDC&quot;, &quot;UInt&quot;, hwnd, &quot;UInt&quot;, hDC)
}
WinGetP(hwnd) {
	WinGetPos, x, y, w, h, ahk_id %hwnd%
	WinP := {x:x, y:y, w:w, h:h}
	VarSetCapacity(pt, 16)
	NumPut(x, pt, 0) || NumPut(y, pt, 4) || NumPut(w, pt, 8) || NumPut(h, pt, 12)
	if (!DllCall(&quot;GetClientRect&quot;, &quot;uint&quot;, hwnd, &quot;uint&quot;, &amp;pt))
		Return
	if (!DllCall(&quot;ClientToScreen&quot;, &quot;uint&quot;, hwnd, &quot;uint&quot;, &amp;pt))
		Return
	x := NumGet(pt, 0, &quot;int&quot;), y := NumGet(pt, 4, &quot;int&quot;)
	w := NumGet(pt, 8, &quot;int&quot;), h := NumGet(pt, 12, &quot;int&quot;)
	ClientScr := {x:x, y:y, w:w, h:h}
	ClientWin := {x:x-WinP.x, y:y-WinP.y, w:w, h:h}
	Return WinP := {x:WinP.x, y:WinP.y, w:WinP.w, h:WinP.h, ClientWin:ClientWin, ClientScr:ClientScr}
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2021-01-02T05:49:50Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=144467#p144467</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: PixelSearch]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=144466#p144466" />
			<content type="html"><![CDATA[<p><strong>stealzy</strong></p><p>Здравствуйте. Помогите мне пожалуйста с вашим кодом. У меня к сожалению не хватает навыков разобраться как заставить ваш код искать цвет одного пикселя в перекрытом окне...</p><p>Если вы можете покажите пожалуйста пример на этот код который у меня хорошо работает но только в активном окне.</p><div class="codebox"><pre><code>{
PixelSearch,,,642,1047,642,1047,0x4eff00,,Fast RGB
If !ErrorLevel
{
Send, {vk57}
Sleep, 200
Send, {vk49}
}
}
return</code></pre></div><p>Извините что беспокою Вас.. У меня уже просто идей нет.<br />С новым годом Вас.</p>]]></content>
			<author>
				<name><![CDATA[SHOX]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=39086</uri>
			</author>
			<updated>2021-01-02T02:12:20Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=144466#p144466</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: PixelSearch]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=131468#p131468" />
			<content type="html"><![CDATA[<p>Все получилось с первым вариантом, спасибо большое</p>]]></content>
			<author>
				<name><![CDATA[Papajaa]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=39894</uri>
			</author>
			<updated>2019-01-21T10:47:25Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=131468#p131468</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: PixelSearch]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=131423#p131423" />
			<content type="html"><![CDATA[<p>Взятие пикселя в перекрытом окне:</p><div class="codebox"><pre><code>exe := &quot;notepad.exe&quot;, x := 2, y := 2
;=======================================
prev := WinExist(&quot;A&quot;)
Run % exe
WinWait % &quot;ahk_exe&quot; exe
hWnd := WinExist(&quot;ahk_exe&quot; exe)
WinActivate % &quot;ahk_id&quot; prev
sleep 100

p := WinGetP(hWnd)
xRel := x + p.ClientWin.x, yRel := y + p.ClientWin.y

hDC := Window_CreateCapture(hWnd)
pix := GetPixel(hDC, xRel, yRel)
Window_DeleteWindowCapture(hWnd, hDC)

MsgBox % Format(&quot;{:#0x}&quot;, pix)
WinClose % &quot;ahk_exe&quot; exe
Return

Window_CreateCapture(hwnd) {
	Return DllCall(&quot;user32.dll\GetDCEx&quot;, &quot;UInt&quot;, hwnd, &quot;UInt&quot;, 0, &quot;UInt&quot;, 1|2)
}
GetPixel(hDC, x, y) {
	Return DllCall(&quot;gdi32.dll\GetPixel&quot;, &quot;UInt&quot;, hDC, &quot;Int&quot;, x, &quot;Int&quot;, y, &quot;UInt&quot;) ; colorBGR
}
Window_DeleteWindowCapture(hwnd, hDC) {
	DllCall(&quot;user32.dll\ReleaseDC&quot;, &quot;UInt&quot;, hwnd, &quot;UInt&quot;, hDC)
}
WinGetP(hwnd) {
	WinGetPos, x, y, w, h, ahk_id %hwnd%
	WinP := {x:x, y:y, w:w, h:h}
	VarSetCapacity(pt, 16)
	NumPut(x, pt, 0) || NumPut(y, pt, 4) || NumPut(w, pt, 8) || NumPut(h, pt, 12)
	if (!DllCall(&quot;GetClientRect&quot;, &quot;uint&quot;, hwnd, &quot;uint&quot;, &amp;pt))
		Return
	if (!DllCall(&quot;ClientToScreen&quot;, &quot;uint&quot;, hwnd, &quot;uint&quot;, &amp;pt))
		Return
	x := NumGet(pt, 0, &quot;int&quot;), y := NumGet(pt, 4, &quot;int&quot;)
	w := NumGet(pt, 8, &quot;int&quot;), h := NumGet(pt, 12, &quot;int&quot;)
	ClientScr := {x:x, y:y, w:w, h:h}
	ClientWin := {x:x-WinP.x, y:y-WinP.y, w:w, h:h}
	Return WinP := {x:WinP.x, y:WinP.y, w:WinP.w, h:WinP.h, ClientWin:ClientWin, ClientScr:ClientScr}
}</code></pre></div><p>Поиск пикселя с gdi (понадобится ahk библиотека GDIP):</p><div class="codebox"><pre><code>SetBatchLines, -1
CoordMode, Pixel, screen
pToken := Gdip_Startup()

SearchPixel := 0xffffffff
; variation := 0x11

Start := A_TickCount
; loop 100 {
	pBitmap := Gdip_BitmapFromScreen(&quot;0|0|1920|1080&quot;)
	width := Gdip_GetImageWidth(pBitmap)
	height := Gdip_GetImageHeight(pBitmap) 
	Gdip_LockBits(pBitmap, 0, 0, width, height, Stride, Scan0, BitmapData)

	bgr1 := SearchPixel
	loop % width + (n:=0)
	{
		A_Index_X := A_Index-1
		loop % height
		{ 
			bgr2 := Gdip_GetLockBitPixel(Scan0, A_Index_X, A_Index-1, Stride)
			; if !(abs((bgr1 &amp; 0xff) - (bgr2 &amp; 0xff)) &gt; variation)
			; &amp;&amp; !(abs(((bgr1 &gt;&gt; 8) &amp; 0xff) - ((bgr2 &gt;&gt; 8) &amp; 0xff)) &gt; variation)
			; &amp;&amp; !(abs(((bgr1 &gt;&gt; 16) &amp; 0xff) - ((bgr2 &gt;&gt; 16) &amp; 0xff)) &gt; variation)
			if (bgr1=bgr2)
				++n
		}
	}
	Gdip_UnlockBits(pBitmap, BitmapData)
	Gdip_DisposeImage(pBitmap)
; }
msgbox % n &quot;`n&quot; A_TickCount - Start
Gdip_Shutdown(pToken)</code></pre></div><p>Теперь сможете собрать как вы любите.</p>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2019-01-18T17:01:04Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=131423#p131423</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: PixelSearch]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=131363#p131363" />
			<content type="html"><![CDATA[<p>Нашел вот такое решение<br /></p><div class="codebox"><pre><code>
CoordMode, Pixel, Screen
F1::
Label1:
Loop,
{
PixelSearch, xp, yp, 1280, 727, 1377, 807, 0xf5b853, 2, Fast
Sleep 3000
If xp &gt; 0
Break
}
msgbox, fghfghfgh
</code></pre></div><p>Но это не совсем то, хочу что бы искало и в перекрытом окне<br />Просто хотелось бы узнать у знающих людей такое возможно или не искать, я то в этих делах ноль. Методом тыка франкинштэйна своего собираю.</p>]]></content>
			<author>
				<name><![CDATA[Papajaa]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=39894</uri>
			</author>
			<updated>2019-01-18T05:50:07Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=131363#p131363</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: PixelSearch]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=131337#p131337" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p>Можно, но не через PixelSearch.</p></blockquote></div><p>Так вроде не было озвучено что окно может быть перекрыто.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-01-17T11:58:54Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=131337#p131337</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: PixelSearch]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=131328#p131328" />
			<content type="html"><![CDATA[<p>Искал и не нашел ни чего толкового, поэтому вот задал вопрос.</p>]]></content>
			<author>
				<name><![CDATA[Papajaa]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=39894</uri>
			</author>
			<updated>2019-01-17T10:01:47Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=131328#p131328</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: PixelSearch]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=131300#p131300" />
			<content type="html"><![CDATA[<p>Можно, но не через PixelSearch. Поищите &quot;PixelSearch для неактивного окна&quot;, уже несколько раз обсуждалось.</p>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2019-01-16T12:08:21Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=131300#p131300</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: PixelSearch]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=131295#p131295" />
			<content type="html"><![CDATA[<p>Всем привет.<br />В игре через BlueStacks скрипт проверяет пиксель и когда цвет совпадает запускается цепочка кликов. Все работает норм но только в активном окне. <br />Можно как то привязать PixelSerch как ControlClick к Блюстаку?<br /></p><div class="codebox"><pre><code>
F1::
Label1:
Loop,
{
PixelSearch, xp, yp, 217, 276, 217, 276, 0xf5b853
Sleep 3000
If xp &gt; 0
Break
}
Random, rand1, 1700, 3500
Random, var1, 33, 795
Random, var2, 55, 470
ControlClick, X%var1% Y%var2%, ahk_exe BlueStacks.exe, ,left ;Клик в экран
Sleep, rand1
Random, var3, 320, 500
Random, var4, 225, 377
ControlClick, X%var3% Y%var4%, ahk_exe BlueStacks.exe, ,left ;Клик в сундук
Sleep, rand1
Random, var7, 362, 407
Random, var8, 396, 425
ControlClick, X%var7% Y%var8%, ahk_exe BlueStacks.exe, ,left ;Продать
Sleep, rand1
Random, var5, 290, 397
Random, var6, 300, 345
ControlClick, X%var5% Y%var6%, ahk_exe BlueStacks.exe, ,left ;OK
Sleep, rand1
Random, var9, 153, 378
Random, var10, 270, 318
ControlClick, X%var9% Y%var10%, ahk_exe BlueStacks.exe, ,left ;Повторить
Goto, Label1
F10::ExitApp
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Papajaa]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=39894</uri>
			</author>
			<updated>2019-01-16T09:10:03Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=131295#p131295</id>
		</entry>
</feed>
