<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Поиск пикселя и щелчок ЛКМ]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=6098&amp;type=atom" />
	<updated>2012-12-14T06:56:10Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=6098</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск пикселя и щелчок ЛКМ]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=66967#p66967" />
			<content type="html"><![CDATA[<p><strong>2TonyMontana</strong></p><div class="quotebox"><cite>TonyMontana пишет:</cite><blockquote><p>Ни один их приведенных вами примеров в D3D не работает...</p></blockquote></div><p>Вообще-то, кто ищет цвет/изображение, или пытается, что-то от рисовать (поверх) в полноэкранных приложениях делают это при условии, что само приложение запускается в оконном режиме. Это является наиболее простым вариантом, нежели вырисовывать, что-то в Direct3D. Вот так к примеру нахожу нужный цвет в CS:S:</p><div class="codebox"><pre><code>Numpad2::
NumpadDown::
   If !hWnd
   {
      offSet:=25
      WinSet, AlwaysOnTop, Off, % &quot;ahk_id&quot;hWnd:=WinActive(&quot;A&quot;)
      WinGetPos, xWnd, yWnd, wWnd, hWnd_, % &quot;ahk_id&quot;hWnd
      WinMove, % &quot;ahk_id&quot;hWnd,, 0, 0, A_ScreenWidth, A_ScreenHeight
      WinSet, Style, -0xC00000, % &quot;ahk_id&quot;hWnd
   }
   Loop, % (isEnable:=!isEnable) ? 1:2
      SoundBeep, 7500, 100
   SetTimer, WatchCursor1, % isEnable ? 100:&quot;Off&quot;
   SetTimer, WatchCursor2, Off
   SetTimer, WatchCursor3, % isEnable ? 100:&quot;Off&quot;
   If !isEnable
      SetTimer, RemoveTips, -100
   KeyWait, % A_ThisHotkey
   Return

~Esc::
   KeyWait, Esc
   If A_TimeSinceThisHotkey&gt;1000
      Goto, ExitScript
   Return

WatchCursor1:
   MouseGetPos, xPos, yPos
   PixelGetColor, currentColor, xPos, yPos, Fast RGB
   PixelSearch,,, xPos-offSet
                , yPos-offSet
                , xPos+offSet
                , yPos+offSet
                , 0xFFFFFF,, Fast RGB
   If !ErrorLevel
   {
;       MouseClick, L,,,,, D
      SetTimer, WatchCursor1, Off
      SetTimer, WatchCursor2, 100

      ToolTip, % &quot;found!`ncurrent: &quot;currentColor &quot;`nxPos: &quot;xPos &quot;, yPos: &quot;yPos
             , A_ScreenWidth-384, A_ScreenHeight-185, 1
      ToolTip,,,, 2
      SoundBeep, 12500, 100
   }
   Return

WatchCursor2:
   MouseGetPos, xPos, yPos
   PixelGetColor, currentColor, xPos, yPos, Fast RGB
   PixelSearch,,, xPos-offSet
                , yPos-offSet
                , xPos+offSet
                , yPos+offSet
                , 0xFFFFFF,, Fast RGB
   If ErrorLevel
   {
;       MouseClick, L,,,,, U
      SetTimer, WatchCursor2, Off
      SetTimer, WatchCursor1, 100

      ToolTip, % &quot;lost!`ncurrent: &quot;currentColor &quot;`nxPos: &quot;xPos &quot;, yPos: &quot;yPos
             , A_ScreenWidth-384, A_ScreenHeight-130, 2
      ToolTip,,,, 1
      SoundBeep, 750, 100
   }
   Return

WatchCursor3:
   MouseGetPos, xPos2, yPos2
   PixelGetColor, currentColor2, xPos2, yPos2, Fast RGB
   ToolTip, % &quot;current (cursor): &quot;currentColor2 &quot;`nxPos: &quot;xPos2 &quot;, yPos: &quot;yPos2
          , A_ScreenWidth-250, A_ScreenHeight-170, 3
   Return

ExitScript:
   WinMove, % &quot;ahk_id&quot;hWnd,, xWnd, yWnd, wWnd, hWnd_
   WinSet, Style, +0xC00000, % &quot;ahk_id&quot;hWnd
   ExitApp

RemoveTips:
   ToolTip,,,, 1
   ToolTip,,,, 2
   ToolTip,,,, 3
   Return</code></pre></div><p>Но такой код не даст результата в BFBC2, всё по тому, что в CS:S курсор приложение &quot;держит&quot; в середине экрана, а в BFBC2 курсор &quot;гуляет&quot; по всему экрану. По этому такой код универсальнее:</p><div class="codebox"><pre><code>OnExit, ExitScript

Numpad2::
NumpadDown::
   If !hWnd
   {
      offSet:=25
      WinSet, AlwaysOnTop, Off, % &quot;ahk_id&quot;hWnd:=WinActive(&quot;A&quot;)
      WinGetPos, xWnd, yWnd, wWnd, hWnd_, % &quot;ahk_id&quot;hWnd
      WinMove, % &quot;ahk_id&quot;hWnd,, 0, 0, A_ScreenWidth, A_ScreenHeight
      WinSet, Style, -0xC00000, % &quot;ahk_id&quot;hWnd
   }
   Loop, % (isEnable:=!isEnable) ? 1:2
      SoundBeep, 7500, 100
   SetTimer, WatchCursor1, % isEnable ? 100:&quot;Off&quot;
   SetTimer, WatchCursor2, Off
   SetTimer, WatchCursor3, % isEnable ? 100:&quot;Off&quot;
   If !isEnable
      SetTimer, RemoveTips, -100
   KeyWait, % A_ThisHotkey
   Return

~Esc::
   KeyWait, Esc
   If A_TimeSinceThisHotkey&gt;1000
      Goto, ExitScript
   Return

WatchCursor1:
   MouseGetPos, xPos, yPos
   PixelGetColor, currentColor, xPos, yPos, Fast RGB
   PixelSearch,,, A_ScreenWidth//2-offSet
                , A_ScreenHeight//2-offSet
                , A_ScreenWidth//2+offSet
                , A_ScreenHeight//2+offSet
                , 0xFFFFFF,, Fast RGB
   If !ErrorLevel
   {
;       MouseClick, L,,,,, D
      SetTimer, WatchCursor1, Off
      SetTimer, WatchCursor2, 100

      ToolTip, % &quot;found!`ncurrent: &quot;currentColor &quot;`nxPos: &quot;xPos &quot;, yPos: &quot;yPos
             , A_ScreenWidth-384, A_ScreenHeight-185, 1
      ToolTip,,,, 2
      SoundBeep, 12500, 100
   }
   Return

WatchCursor2:
   MouseGetPos, xPos, yPos
   PixelGetColor, currentColor, xPos, yPos, Fast RGB
   PixelSearch,,, A_ScreenWidth//2-offSet
                , A_ScreenHeight//2-offSet
                , A_ScreenWidth//2+offSet
                , A_ScreenHeight//2+offSet
                , 0xFFFFFF,, Fast RGB
   If ErrorLevel
   {
;       MouseClick, L,,,,, U
      SetTimer, WatchCursor2, Off
      SetTimer, WatchCursor1, 100

      ToolTip, % &quot;lost!`ncurrent: &quot;currentColor &quot;`nxPos: &quot;xPos &quot;, yPos: &quot;yPos
             , A_ScreenWidth-384, A_ScreenHeight-130, 2
      ToolTip,,,, 1
      SoundBeep, 750, 100
   }
   Return

WatchCursor3:
   MouseGetPos, xPos2, yPos2
   PixelGetColor, currentColor2, xPos2, yPos2, Fast RGB
   PixelGetColor, currentColor3, A_ScreenWidth//2, A_ScreenHeight//2, Fast RGB
   ToolTip, % &quot;current (cursor): &quot;currentColor2 &quot;`nxPos: &quot;xPos2 &quot;, yPos: &quot;yPos2
          , A_ScreenWidth-250, A_ScreenHeight-170, 3
   ToolTip, % &quot;current (center): &quot;currentColor3
          . &quot;`nxPos: &quot;A_ScreenWidth//2 &quot;, yPos: &quot;A_ScreenHeight//2
          , A_ScreenWidth-250, A_ScreenHeight-130, 4
   Return

RemoveTips:
   ToolTip,,,, 1
   ToolTip,,,, 2
   ToolTip,,,, 3
   ToolTip,,,, 4
   Return

ExitScript:
   WinMove, % &quot;ahk_id&quot;hWnd,, xWnd, yWnd, wWnd, hWnd_
   WinSet, Style, +0xC00000, % &quot;ahk_id&quot;hWnd
   ExitApp</code></pre></div><div class="quotebox"><cite>TonyMontana пишет:</cite><blockquote><p>...все D3D (последние лет 7 точно) используют RGBA .</p></blockquote></div><p>Не вижу проблемы, так как в PixelSearch есть параметр отвечающий за вариацию искомого цвета.</p><div class="quotebox"><cite>TonyMontana пишет:</cite><blockquote><p>...D3D использует X,Y,Z систему координат.</p></blockquote></div><p>Мне как-то всё равно на сей счёт, ибо aимбoтaми не занимаюсь. Если нужно сдвинуть курсор, то это прекрасно получается через X, Y.</p>]]></content>
			<author>
				<name><![CDATA[Grey]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=25792</uri>
			</author>
			<updated>2012-12-14T06:56:10Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=66967#p66967</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск пикселя и щелчок ЛКМ]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=66950#p66950" />
			<content type="html"><![CDATA[<p>Прошу прощения что страрую тему поднимаю.<br /><strong>2 Grey:</strong><br />Ни один их приведенных вами примеров в D3D не работает -поверял в 3х пректах.</p><p>Причины всего 2:</p><p><strong>1)</strong>AHK использует RGB определение цвета, а все D3D (последние лет 7 точно) используют RGBA .Добавляется альфа канал.<br />(Приведенный в коде синий цвет, долже быть 0000FFFF в этом случае.)<br />Можно ли в AHK задать RGBA из документации я не понял. скорее всего нужно делать вызов<br /> сторонней DLL</p><p><strong>2)</strong>D3D использует X,Y,Z систему координат.</p>]]></content>
			<author>
				<name><![CDATA[TonyMontana]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=29253</uri>
			</author>
			<updated>2012-12-13T15:54:58Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=66950#p66950</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск пикселя и щелчок ЛКМ]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=50469#p50469" />
			<content type="html"><![CDATA[<p>Если по принципу множественных кликов когда под курсором нужный цвет, то вот как вариант:</p><div class="codebox"><pre><code>SetTimer, WatchCursor, 100 ; частота таймера
WatchCursor:
   MouseGetPos, XPos, YPos
   PixelGetColor, CurrentColor, XPos, YPos, Slow RGB
   If CurrentColor = 0x0000FF ; к примеру синий
      Click ; посылается левый клик с частотой таймера
   Return</code></pre></div><p>, если принцип есть_цвет_зажал/нет_цвета_отпустил:</p><div class="codebox"><pre><code>SetTimer, WatchCursor1, 100
WatchCursor1:
   MouseGetPos, XPos, YPos
   PixelSearch,,, XPos-25
                , YPos-25
                , XPos+25
                , YPos+25
                , 0x0000FF,, Fast RGB ; зона поиска 50х50 от центра курсора
   If !ErrorLevel
   {
      MouseClick, L,,,,, D
      SetTimer, WatchCursor1, Off
      SetTimer, WatchCursor2, 100
   }
   Return
WatchCursor2:
   MouseGetPos, XPos, YPos
   PixelSearch,,, XPos-25
                , YPos-25
                , XPos+25
                , YPos+25
                , 0x0000FF,, Fast RGB
   If ErrorLevel
   {
      MouseClick, L,,,,, U
      SetTimer, WatchCursor2, Off
      SetTimer, WatchCursor1, 100
   }
   Return</code></pre></div><p>, второй вариант универсальнее, в нём можно расширить зону поиска вокруг курсора, задать оттенки искомого цвета, нет блокировки самого левого клика в то время когда цвет не найден.</p>]]></content>
			<author>
				<name><![CDATA[Grey]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=25792</uri>
			</author>
			<updated>2011-08-09T02:56:44Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=50469#p50469</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск пикселя и щелчок ЛКМ]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=50456#p50456" />
			<content type="html"><![CDATA[<p>Если точка &quot;определена&quot; то известны её координаты.<br />Если есть понятие &quot;определённый пиксель&quot; то есть значение цвета сего пикселя.<br /><a href="http://www.autohotkey.com/docs/commands/PixelGetColor.htm">PixelGetColor</a></p><p>Если желаемое действие - клик: <a href="http://www.autohotkey.com/docs/commands/MouseClick.htm">MouseClick</a></p><p>На всякий случай: <a href="http://www.autohotkey.com/docs/commands.htm">Список команд Autohotkey</a></p>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2011-08-08T10:24:59Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=50456#p50456</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Поиск пикселя и щелчок ЛКМ]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=50448#p50448" />
			<content type="html"><![CDATA[<p>Когда в опр. точке появляется опр. пискель, то скрипт делает команду, в данном случае - Клик.<br />Так вот, помогите, в PixelSearch вообще&nbsp; не шарю.</p>]]></content>
			<author>
				<name><![CDATA[Nek1t98]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27075</uri>
			</author>
			<updated>2011-08-08T07:40:27Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=50448#p50448</id>
		</entry>
</feed>
