<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK | BF2: Выбор пункта контекстного меню в игре]]></title>
		<link>http://forum.script-coding.com/viewtopic.php?id=12675</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=12675&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK | BF2: Выбор пункта контекстного меню в игре».]]></description>
		<lastBuildDate>Thu, 18 May 2017 03:34:30 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK | BF2: Выбор пункта контекстного меню в игре]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115920#p115920</link>
			<description><![CDATA[<p><strong>stealzy</strong> приношу извинения, что не отвечал, был на сутках и только сейчас еду домой.<br />Насколько я понял, Ваш код определяет положение курсора и выводит данные о нем в виде окна с текстом.<br />Этим скриптом я определяю нижний &quot;порог&quot;, при котором курсор встаёт на нужный угол.<br />Далее, мне нужно будет сделать так, чтобы перенос курсора по оси Y изменялся при пересечении этого &quot;порога&quot; на некую переменную, которая зависит о того, насколько сильно курсор &quot;зашел&quot; за этот &quot;порог&quot;.</p><p>Решение,конечно, отличное, но я никогда не работал с переменными в AHK (не осилил). Я всегда использовал только статичные значения.<br />Тем более, я так понял, что придётся использовать if, а им пользоваться я не умею</p>]]></description>
			<author><![CDATA[null@example.com (sapmortimer)]]></author>
			<pubDate>Thu, 18 May 2017 03:34:30 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115920#p115920</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK | BF2: Выбор пункта контекстного меню в игре]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115890#p115890</link>
			<description><![CDATA[<p>Самого себя цитировать тоже не стоило.<br />Методом тыка находите граничное значение координаты у, при котором меню показывается сверху от курсора:<br /></p><div class="codebox"><pre><code>~RButton::
	MouseGetPos x, y
	ToolTip % y ; если не виден поверх игры, замените на msgbox
	Return</code></pre></div><p>Меняете основной код:<br />Перед функцией перемещения находите текущее положение курсора по оси у,<br />в зависимости от того, больше текущее положение граничного значения или меньше,<br />присваиваете некой переменной значение 30 или -30,<br />вторым параметром ф-ии перемещения (у) ставите эту переменную.</p>]]></description>
			<author><![CDATA[null@example.com (stealzy)]]></author>
			<pubDate>Tue, 16 May 2017 11:44:19 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115890#p115890</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK | BF2: Выбор пункта контекстного меню в игре]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115868#p115868</link>
			<description><![CDATA[<p><strong>stealzy</strong>, SendPlay не работает на платформах win8 и win8.1<br /></p><div class="quotebox"><cite>sapmortimer пишет:</cite><blockquote><p>а SendInpit/Event так же реагирует через раз.</p></blockquote></div>]]></description>
			<author><![CDATA[null@example.com (sapmortimer)]]></author>
			<pubDate>Mon, 15 May 2017 15:10:41 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115868#p115868</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK | BF2: Выбор пункта контекстного меню в игре]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115864#p115864</link>
			<description><![CDATA[<p><strong>stealzy</strong> забыл уточнить: у меня Win 8.1, а SendInpit/Event так же реагирует через раз.</p><p>Применил старый метод с МТА:SA:</p><div class="codebox"><pre><code>Send {click, down}
  Sleep, 20
  Send {click, up}</code></pre></div><p> Работает безотказно, но есть существенный минус: скорость ниже.</p><p>UPD: Тут возник один казус: при вызове контекстного меню ближе к нижней границе карты, контекстное меню &quot;поднимается&quot; чуть выше курсора (при вызове меню, курсор встаёт не у верхнего левого угла, а ниже или вообще у нижнего угла) и скрипт промахивается.</p><p>Есть способ научить AHK определять контекстное меню и выбирать нужный пункт из него?</p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><p>Спасибо, возьму на вооружение<br /></p><div class="quotebox"><cite>Ядрён пишет:</cite><blockquote><p>Доброго времени суток. Попробуйте так, <strong>sapmortimer</strong>.<br /></p><div class="codebox"><pre><code>x := 10

y := 30

XButton1::

DllCall(&quot;mouse_event&quot;, UInt, 0x0008, Int, 0, Int, 0, UInt, 0, Int, 0) ; нажать правую кнопку мыши
      
DllCall(&quot;mouse_event&quot;, UInt, 0x0010, Int, 0, Int, 0, UInt, 0, Int, 0) ; отпустить правую кнопку мыши

DllCall(&quot;mouse_event&quot;, uint, 1, int, x, int, y, uint, 0, int, 0) ; координаты по оси &quot;x&quot; &quot;y&quot; относительно курсора

DllCall(&quot;Sleep&quot;, UInt, 400) ; задержка

DllCall(&quot;mouse_event&quot;, UInt, 0x02, Int, 0, Int, 0, UInt, 0, Int, 0) ; нажать левую кнопку мыши
      
DllCall(&quot;mouse_event&quot;, UInt, 0x04, Int, 0, Int, 0, UInt, 0, Int, 0) ; отпустить левую кнопку мыши

Return</code></pre></div></blockquote></div></div></div>]]></description>
			<author><![CDATA[null@example.com (sapmortimer)]]></author>
			<pubDate>Mon, 15 May 2017 09:37:28 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115864#p115864</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK | BF2: Выбор пункта контекстного меню в игре]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115862#p115862</link>
			<description><![CDATA[<p>Доброго времени суток. Попробуйте так, <strong>sapmortimer</strong>.<br /></p><div class="codebox"><pre><code>x := 10

y := 30

XButton1::

DllCall(&quot;mouse_event&quot;, UInt, 0x0008, Int, 0, Int, 0, UInt, 0, Int, 0) ; нажать правую кнопку мыши
      
DllCall(&quot;mouse_event&quot;, UInt, 0x0010, Int, 0, Int, 0, UInt, 0, Int, 0) ; отпустить правую кнопку мыши

DllCall(&quot;mouse_event&quot;, uint, 1, int, x, int, y, uint, 0, int, 0) ; координаты по оси &quot;x&quot; &quot;y&quot; относительно курсора

DllCall(&quot;Sleep&quot;, UInt, 400) ; задержка

DllCall(&quot;mouse_event&quot;, UInt, 0x02, Int, 0, Int, 0, UInt, 0, Int, 0) ; нажать левую кнопку мыши
      
DllCall(&quot;mouse_event&quot;, UInt, 0x04, Int, 0, Int, 0, UInt, 0, Int, 0) ; отпустить левую кнопку мыши

Return</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Ядрён)]]></author>
			<pubDate>Sun, 14 May 2017 20:20:04 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115862#p115862</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK | BF2: Выбор пункта контекстного меню в игре]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115848#p115848</link>
			<description><![CDATA[<p><strong>stealzy</strong>, оч сложна, можно объяснить, как для дебила?<br />Мне ведь еще нужно задать нажатие на ПКМ, слип, движение мыши, слип, ЛКМ<br />Я так понял, должно получиться это:<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><div class="codebox"><pre><code>; =========== Sample script ============================================================
#SingleInstance,Force

XButton1::
  MouseClick, right
  Sleep, 100
  LLMouse.Move(30, 30)
  Sleep, 200
  MouseClick
  Sleep, 100
  LLMouse.Move(-30, -30)
Return

; =======================================================================================
; LLMouse - A library to send Low Level Mouse input

; Note that many functions have time and rate parameters.
; These all work the same way:
; times	- How many times to send the requested action. Optional, default is 1
; rate	- The rate (in ms) to send the action at. Optional, default rate varies
; Note that if you use a value for rate of less than 10, special code will kick in.
; QPX is used for rates of &lt;10ms as the AHK Sleep command does not support sleeps this short
; More CPU will be used in this mode.
class LLMouse {
	static MOUSEEVENTF_MOVE := 0x1
	static MOUSEEVENTF_WHEEL := 0x800
	
	; ======================= Functions for the user to call ============================
	; Move the mouse
	; All values are Signed Integers (Whole numbers, Positive or Negative)
	; x		- How much to move in the x axis. + is right, - is left
	; y		- How much to move in the y axis. + is down, - is up
	Move(x, y, times := 1, rate := 1){
		this._MouseEvent(times, rate, this.MOUSEEVENTF_MOVE, x, y)
	}
	
	; Move the wheel
	; dir	- Which direction to move the wheel. 1 is up, -1 is down
	Wheel(dir, times := 1, rate := 10){
		static WHEEL_DELTA := 120
		this._MouseEvent(times, rate, this.MOUSEEVENTF_WHEEL, , , dir * WHEEL_DELTA)
	}
	
	; ============ Internal functions not intended to be called by end-users ============
	_MouseEvent(times, rate, dwFlags := 0, dx := 0, dy := 0, dwData := 0){
		Loop % times {
			DllCall(&quot;mouse_event&quot;, uint, dwFlags, int, dx ,int, dy, uint, dwData, int, 0)
			if (A_Index != times){	; Do not delay after last send, or if rate is 0
				if (rate &gt;= 10){
					Sleep % rate
				} else {
					this._Delay(rate * 0.001)
				}
			}
		}
	}
	
	_Delay( D=0.001 ) { ; High Resolution Delay ( High CPU Usage ) by SKAN | CD: 13/Jun/2009
		Static F ; www.autohotkey.com/forum/viewtopic.php?t=52083 | LM: 13/Jun/2009
		Critical
		F ? F : DllCall( &quot;QueryPerformanceFrequency&quot;, Int64P,F )
		DllCall( &quot;QueryPerformanceCounter&quot;, Int64P,pTick ), cTick := pTick
		While( ( (Tick:=(pTick-cTick)/F)) &lt;D ) {
			DllCall( &quot;QueryPerformanceCounter&quot;, Int64P,pTick )
			Sleep -1
		}
		Return Round( Tick,3 )
	}
}</code></pre></div></div></div><p>Но нажатия клавиш все равно пропускаются (что логично).<br />Есть такая же low-level штука для нажатий клавиш мыши?</p>]]></description>
			<author><![CDATA[null@example.com (sapmortimer)]]></author>
			<pubDate>Sun, 14 May 2017 17:18:02 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115848#p115848</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK | BF2: Выбор пункта контекстного меню в игре]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115846#p115846</link>
			<description><![CDATA[<p>Игра перехватывает мышиный ввод на низком уровне.<br />Берешь <a href="https://autohotkey.com/boards/viewtopic.php?t=26137">библиотеку LLMouse</a>, вместо примера в верхней части вставляешь:<br /></p><div class="codebox"><pre><code>XButton1::LLMouse.Move(30, 30)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (stealzy)]]></author>
			<pubDate>Sun, 14 May 2017 17:03:59 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115846#p115846</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK | BF2: Выбор пункта контекстного меню в игре]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115845#p115845</link>
			<description><![CDATA[<p>Протестировал ещё и заметил вот что: в экране загрузки курсор нормально выполняет команды, но в режиме игры (особенно заметно при открытой карте) курсор лихорадочно дергается в рандомное направление и пропускает нажатие клавиш ЛКМ и ПКМ.<br />Такое чувство, будто игра неадекватно воспринимает эмуляцию движения и нажатия клавиш мыши<br />UPD: в оконном режиме не лучше</p>]]></description>
			<author><![CDATA[null@example.com (sapmortimer)]]></author>
			<pubDate>Sun, 14 May 2017 16:57:55 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115845#p115845</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK | BF2: Выбор пункта контекстного меню в игре]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115844#p115844</link>
			<description><![CDATA[<p><strong>stealzy</strong>, так же, как и на видео</p>]]></description>
			<author><![CDATA[null@example.com (sapmortimer)]]></author>
			<pubDate>Sun, 14 May 2017 16:46:14 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115844#p115844</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK | BF2: Выбор пункта контекстного меню в игре]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115843#p115843</link>
			<description><![CDATA[<p>Скорость крутил, по остальным двум пунктам что?<br />Такой код как работает:<br /></p><div class="codebox"><pre><code>XButton1::MouseMove 30, 30, 2, R</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (stealzy)]]></author>
			<pubDate>Sun, 14 May 2017 16:35:37 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115843#p115843</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK | BF2: Выбор пункта контекстного меню в игре]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115842#p115842</link>
			<description><![CDATA[<div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p>Я бы попробывал SendMode Play, уменьшение скорости перемещения курсора и BlockInput.</p></blockquote></div><p>Скорость крутил, но дело в том, что он берет исходную точку черте-знает-откуда и отталкивается уже от нее.<br />Наглядно вот здесь: <a href="https://youtu.be/PG3z6zvGpIk">https://youtu.be/PG3z6zvGpIk</a></p>]]></description>
			<author><![CDATA[null@example.com (sapmortimer)]]></author>
			<pubDate>Sun, 14 May 2017 14:44:41 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115842#p115842</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK | BF2: Выбор пункта контекстного меню в игре]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115841#p115841</link>
			<description><![CDATA[<div class="quotebox"><cite>Indomito пишет:</cite><blockquote><p>Как я понял у тебя полноэкранное приложение/игра по этому лучше использовать <strong>CoordMode, Mouse, Screen </strong>, а не <strong>CoordMode, Mouse, Window</strong>, но из видио это не ясно...</p></blockquote></div><p>Сейчас полечим видео. Выложил необработанное с дохлым звуком.<br />Новая ссылка: https://youtu.be/PG3z6zvGpIk<br /></p><div class="quotebox"><cite>sapmortimer пишет:</cite><blockquote><p>Пробовал заменять на &quot;CoordMode, Mouse, Screen&quot;</p></blockquote></div><p>Не помогло.</p>]]></description>
			<author><![CDATA[null@example.com (sapmortimer)]]></author>
			<pubDate>Sun, 14 May 2017 14:42:59 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115841#p115841</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK | BF2: Выбор пункта контекстного меню в игре]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115840#p115840</link>
			<description><![CDATA[<p><strong>sapmortimer</strong><br />Небольшой пример кода, думаю тебе поможет. </p><div class="codebox"><pre><code>CoordMode, Mouse, Screen  ;|Window|Client]
  SetMouseDelay, 10
  MouseGetPos, xPos, yPos
  ; The first number is the X-coordinate and the second is the Y (relative to the screen).
  ;DllCall(&quot;SetCursorPos&quot;, int, 100, int, 400)
  xPos  := xPos + 5
  MouseMove, xPos,yPos,50
  ;Sleep 50
Return</code></pre></div><p> Как я понял у тебя полноэкранное приложение/игра по этому лучше использовать <strong>CoordMode, Mouse, Screen </strong>, а не <strong>CoordMode, Mouse, Window</strong>, но из видио это не ясно...</p>]]></description>
			<author><![CDATA[null@example.com (Indomito)]]></author>
			<pubDate>Sun, 14 May 2017 14:34:39 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115840#p115840</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK | BF2: Выбор пункта контекстного меню в игре]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115839#p115839</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>Пробовал заменять на &quot;CoordMode, Mouse, Screen&quot;, а &quot;Send {Click}&quot; на &quot;MouseClick&quot;</p></blockquote></div><p>Зачем? Смещение у вас все равно относительное - R, a Send {Click}, Click и MouseClick одно и тоже.<br />Я бы попробывал SendMode Play, уменьшение скорости перемещения курсора и BlockInput.</p>]]></description>
			<author><![CDATA[null@example.com (stealzy)]]></author>
			<pubDate>Sun, 14 May 2017 14:30:33 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115839#p115839</guid>
		</item>
		<item>
			<title><![CDATA[AHK | BF2: Выбор пункта контекстного меню в игре]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=115838#p115838</link>
			<description><![CDATA[<p>Аве, друзья!<br />С AHK знаком достаточно давно, но с перемещениями мыши ранее не игрался, поэтому возникла одна проблема.<br />Суть: нужно, чтобы при нажатии на кнопку мыши (дополнительную - XButton1) нажималась правая кнопка мыши, курсор смещался чуть ниже и правее (пока не высчитал координаты) и нажималась левая кнопка мыши через некоторый промежуток времени.<br />Я создал нечто подобное:<br /></p><div class="codebox"><pre><code>CoordMode, Mouse, Window
XButton1::
  Send {Click, right}
  MouseMove, 2, 5, 20, R
  Sleep, 200
  Send {Click}
Return</code></pre></div><p>Проблема в том, что нажатия мыши срабатывают через раз, а перемещение курсора происходит хаотично - каждый раз в новое место.<br />Пробовал заменять на &quot;CoordMode, Mouse, Screen&quot;, а &quot;Send {Click}&quot; на &quot;MouseClick&quot; - толку немного.<br />Более наглядно можно посмотреть здесь:<br /><a href="https://youtu.be/PG3z6zvGpIk">https://youtu.be/PG3z6zvGpIk</a><br />Спасибо за внимание!</p>]]></description>
			<author><![CDATA[null@example.com (sapmortimer)]]></author>
			<pubDate>Sun, 14 May 2017 14:14:18 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=115838#p115838</guid>
		</item>
	</channel>
</rss>
