<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: 2+ цикла в цикле, +старт по состоянию "хоткея"]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=12979</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=12979&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: 2+ цикла в цикле, +старт по состоянию "хоткея"».]]></description>
		<lastBuildDate>Fri, 08 Sep 2017 11:51:26 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: 2+ цикла в цикле, +старт по состоянию "хоткея"]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=119171#p119171</link>
			<description><![CDATA[<p><strong>stealzy</strong><br />Спасибо большое я Вас понял.</p>]]></description>
			<author><![CDATA[null@example.com (romzes96)]]></author>
			<pubDate>Fri, 08 Sep 2017 11:51:26 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=119171#p119171</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: 2+ цикла в цикле, +старт по состоянию "хоткея"]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=119165#p119165</link>
			<description><![CDATA[<div class="quotebox"><cite>romzes96 пишет:</cite><blockquote><p>Можно остановку скрипта сделать по &quot;отпусканию&quot; любой из кнопок. (?)</p></blockquote></div><div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p>вам понадобятся скобки и оператор OR.</p></blockquote></div>]]></description>
			<author><![CDATA[null@example.com (stealzy)]]></author>
			<pubDate>Thu, 07 Sep 2017 19:09:59 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=119165#p119165</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: 2+ цикла в цикле, +старт по состоянию "хоткея"]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=119160#p119160</link>
			<description><![CDATA[<div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p>чтобы мышь перестала двигаться по отпусканию левой кнопки мыши?</p></blockquote></div><p>Можно остановку скрипта сделать по &quot;отпусканию&quot; любой из кнопок. (?) (Ctrl, ЛКМ) (В обоих &quot;сценариях&quot;)</p>]]></description>
			<author><![CDATA[null@example.com (romzes96)]]></author>
			<pubDate>Thu, 07 Sep 2017 15:21:33 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=119160#p119160</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: 2+ цикла в цикле, +старт по состоянию "хоткея"]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=119158#p119158</link>
			<description><![CDATA[<p>Давайте без соплей &quot;помогите пожалуйста&quot; и &quot;попросить помощи&quot;.<br />Чтобы не писать вручную такие циклы можно воспользоваться LLMouse - готовой наработкой для низкоуровнего (≈для игр) движения мышкой.<br />Цикл конечно, никуда ни денется, просто он переезжает внутрь ф-ии и не мозолит глаза. Таким образом код становится гораздо понятнее.<br /></p><div class="codebox"><pre><code>#SingleInstance,Force
F11::LLMouse.Wheel(-1, 2, 100) ; Send 2x mouse wheel down rolls at rate of 100ms

~LCtrl &amp; ~LButton::
	LLMouse.Move(0, 1, 300, 5) ; y+0, x+1; 300 moves * 5ms = 1,5s
	LLMouse.Move(-1, 1, 300, 5)
	LLMouse.Move(1, 1, 300, 5)
	Return

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

; 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><p>Вот вам загадка: в какое место нужно добавить нижележащий код, чтобы мышь перестала двигаться по отпусканию левой кнопки мыши? (Return это аналог Break для функций).<br /></p><div class="codebox"><pre><code>If Not GetKeyState(&quot;LButton&quot;)
	Return</code></pre></div><p>Кстати команду GetKeyState вы использовали с ошибкой - прочитайте про нее в справке. Чтобы написать правильно, вам понадобятся скобки и оператор OR.</p>]]></description>
			<author><![CDATA[null@example.com (stealzy)]]></author>
			<pubDate>Thu, 07 Sep 2017 14:27:59 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=119158#p119158</guid>
		</item>
		<item>
			<title><![CDATA[AHK: 2+ цикла в цикле, +старт по состоянию "хоткея"]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=119157#p119157</link>
			<description><![CDATA[<p>Здравствуйте дорогие форумчане.<br />Я тут не дано и пока не все понимаю <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" /> Хотел бы попросить помощи.<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>#NoEnv
SendMode Input

~F6::Suspend

~End::ExitApp

~LCtrl &amp; ~LButton::
Loop
	If GetKeyState(&quot;LButton&quot;, &quot;LCtrl&quot;) {
		Sleep, 1
		moveAmount := (moveAmount = 2) ? 3 : 0
 		mouseXY(moveAmount,4.2)
		
	}
	else
	break
	
Return



mouseXY(x,y)
{
DllCall(&quot;mouse_event&quot;,int,1,int,x,int,y,uint,0,uint,0)
}</code></pre></div></div></div><p>&quot;Цикл внутри цикла, с интервалом&quot;</p><p>Сейчас скрипт работает так:<br />Скрипт просто плавно ведёт курсор вниз. При нажатие Ctrl+ЛКМ. При отжатие лкм или контрола курсор останавливаться.</p><p>А надо сделать так:<br />Что бы при нажатие на ctrl+лкм курсор плавно опускался вниз, а через 1.5 секунды двигался вниз по &quot;косой&quot;, по диоганали влево, ещё через 1.5 секунда двигался вниз по диоганали вправо. При отжиме ctrl или лкм скрипт останавливался.</p><p>Как я понял должно быть 3 или 4 цикла, но я не понимаю как сделать так что бы они работали последовательно друг за другом. Но назначено все это было на ctrl+лкм. Что бы когда отжал ctrl или лкм все останавливалось.</p><p>Помогите пожалуйста.<br />Спасибо!</p>]]></description>
			<author><![CDATA[null@example.com (romzes96)]]></author>
			<pubDate>Thu, 07 Sep 2017 10:25:56 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=119157#p119157</guid>
		</item>
	</channel>
</rss>
