<?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="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11476&amp;type=atom" />
	<updated>2016-04-07T00:26:49Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=11476</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать цикл который обрывается сразу после отжатия клавиши?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102361#p102361" />
			<content type="html"><![CDATA[<p>Спасибо!Теперь отлично.</p>]]></content>
			<author>
				<name><![CDATA[Ox1de]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33811</uri>
			</author>
			<updated>2016-04-07T00:26:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102361#p102361</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать цикл который обрывается сразу после отжатия клавиши?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102346#p102346" />
			<content type="html"><![CDATA[<p>Вероятнее всего нажатие происходить в момент когда скрипт ждет Sleep 400, вылечить можно добавив переменную:<br /></p><div class="codebox"><pre><code>rcontrol::
WhileSend7:=1
KeyWait, rcontrol
while (!GetKeyState(&quot;rcontrol&quot;, &quot;P&quot;) And WhileSend7 = 1) {
Send 7
Sleep 400
}
Return
#If WhileSend7
rcontrol::WhileSend7:=0</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Nikva]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27416</uri>
			</author>
			<updated>2016-04-06T05:41:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102346#p102346</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать цикл который обрывается сразу после отжатия клавиши?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102331#p102331" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>rcontrol::
KeyWait, rcontrol
while !GetKeyState(&quot;rcontrol&quot;, &quot;P&quot;) {
Send 7
Sleep 400
}
Return </code></pre></div><p>Вроде все так и сделал,но цикл то идет,а останавливается как-то рандомно,то со 2 то с 3 нажатия,где я мог ошибиться?</p>]]></content>
			<author>
				<name><![CDATA[Ox1de]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33811</uri>
			</author>
			<updated>2016-04-05T17:31:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102331#p102331</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать цикл который обрывается сразу после отжатия клавиши?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102325#p102325" />
			<content type="html"><![CDATA[<p><strong>Ox1de</strong></p><div class="codebox"><pre><code>1::
KeyWait, 1
while !GetKeyState(&quot;1&quot;, &quot;P&quot;) {
Send 2
Sleep 100
}
Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Nikva]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27416</uri>
			</author>
			<updated>2016-04-05T15:34:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102325#p102325</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать цикл который обрывается сразу после отжатия клавиши?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102322#p102322" />
			<content type="html"><![CDATA[<p>Все-таки, удалось написать с ExitApp. Ограничение такого метода в том, что между нажатиями клавиши нужен промежуток времени в 300-500 милисекунд (пока скрипт новый запустится) <br /></p><div class="codebox"><pre><code>#SingleInstance off
#NoEnv
#UseHook On
SetBatchLines, -1
SetKeyDelay -1

Interval := 10

1::
	SetTimer timer, 0
	While GetKeyState(&quot;1&quot;,&quot;P&quot;) {
		Send 1
		Sleep %Interval%
		Send 2
		Sleep %Interval%
		Send 3
		Sleep %Interval%
		Send 4
		Sleep %Interval%
		Send 5
		Sleep %Interval%
		Send 6
	}
	return

timer:
	if !GetKeyState(&quot;1&quot;,&quot;P&quot;)
	{
		Run %A_ScriptFullPath%
		ExitApp
	}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[mafckz]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32877</uri>
			</author>
			<updated>2016-04-05T14:15:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102322#p102322</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать цикл который обрывается сразу после отжатия клавиши?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102321#p102321" />
			<content type="html"><![CDATA[<p>То что нужно получилось! Спасибо ребята! Nikva отдельное спасибо! А подскажите еще вот такой момент : нужно к примеру на клавишу 1 сделать цикл клавиши 2 и что бы он включался клавишей 1 и воспроизводился до бесконечности и этой же клавишей 1 выключался.&nbsp; </p><p>P.s. Заранее извиняюсь если много вопросов.</p>]]></content>
			<author>
				<name><![CDATA[Ox1de]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33811</uri>
			</author>
			<updated>2016-04-05T14:02:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102321#p102321</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать цикл который обрывается сразу после отжатия клавиши?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102320#p102320" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>mafckz пишет:</cite><blockquote><p>с  #SingleInstance force  создаются дубликаты скрипта (десятки и сотни)</p></blockquote></div><p>Я лечу такие скрипты добавлением в начало это кода:<br /></p><div class="codebox"><pre><code>DetectHiddenWindows, on
IfWinExist, % A_ScriptName
ExitApp</code></pre></div><p>В ahk скриптах всегда есть скрытое окно, и если уже существует окно с именем скрипта, он тут же завершится.</p>]]></content>
			<author>
				<name><![CDATA[Nikva]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27416</uri>
			</author>
			<updated>2016-04-05T13:42:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102320#p102320</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать цикл который обрывается сразу после отжатия клавиши?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102317#p102317" />
			<content type="html"><![CDATA[<p>Поэксперементировал с Reload, чтобы при отпускании клавиши (проверка через таймер) скрипт перезагружался - не получилось, даже с&nbsp; #SingleInstance force&nbsp; создаются дубликаты скрипта (десятки и сотни). Если скомпилировать скрипт и использовать ExitApp, то можно сделать в паре с другим отдельным скриптом, который будет запускать скомпилированный скрипт (рабочий) при его отсутствии (в процессах).</p><p>А так, видимо, пириведенный выше вариант самый &quot;дубовый&quot;.</p><p>Можно сделать немного лаконичней код с помощью функции:<br /></p><div class="codebox"><pre><code>ExitIfKeyIsUp(key) {
	If !(GetKeyState(key,&quot;P&quot;))
		Exit	
}

sc4f::
   Loop
   {
      Send, {10
	  ExitIfKeyIsUp(&quot;sc4f&quot;)
      Send, {sc41}
	  ExitIfKeyIsUp(&quot;sc4f&quot;)
      Sleep, 10
	  ExitIfKeyIsUp(&quot;sc4f&quot;)
      Send, {sc44}
      Sleep, 10
	  ExitIfKeyIsUp(&quot;sc4f&quot;)
      Send, {sc43}
      Sleep, 10
	  ExitIfKeyIsUp(&quot;sc4f&quot;)
      Send, {sc42}
      Sleep, 10
	  ExitIfKeyIsUp(&quot;sc4f&quot;)
      Send, {sc41}
      Sleep, 10
	  ExitIfKeyIsUp(&quot;sc4f&quot;)
   }
   Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[mafckz]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32877</uri>
			</author>
			<updated>2016-04-05T13:07:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102317#p102317</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать цикл который обрывается сразу после отжатия клавиши?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102314#p102314" />
			<content type="html"><![CDATA[<p>У меня нажимает, попробуйте <a href="http://www.script-coding.com/AutoHotkey/SetKeyDelay.html">SetKeyDelay</a>.<br /></p><div class="codebox"><pre><code>SetKeyDelay, 100, 50
sc4f:: ; NumpadEnd
   Loop
   {
      Send, {10
      Send, {sc41} ; F7
      Sleep, 10
      If !GetKeyState(&quot;sc4f&quot;, &quot;P&quot;)
         Break
      Send, {sc44} ; F10
      Sleep, 10
      If !GetKeyState(&quot;sc4f&quot;, &quot;P&quot;)
         Break
      Send, {sc43} ; F9
      Sleep, 10
      If !GetKeyState(&quot;sc4f&quot;, &quot;P&quot;)
         Break
      Send, {sc42} ; F8
      Sleep, 10
      If !GetKeyState(&quot;sc4f&quot;, &quot;P&quot;)
         Break
      Send, {sc41} ; F7
      Sleep, 10
      If !GetKeyState(&quot;sc4f&quot;, &quot;P&quot;)
         Break
   }
   Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Nikva]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27416</uri>
			</author>
			<updated>2016-04-05T12:48:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102314#p102314</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать цикл который обрывается сразу после отжатия клавиши?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102312#p102312" />
			<content type="html"><![CDATA[<p><strong>Nikva</strong> Шикарно, вот то что нужно казалось бы, но почему таким способом&nbsp; ф1-ф12 не хотят нажиматься?</p><br /><p>P.s&nbsp; Разобрался, спасибо тебе большое!</p>]]></content>
			<author>
				<name><![CDATA[Ox1de]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33811</uri>
			</author>
			<updated>2016-04-05T12:42:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102312#p102312</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать цикл который обрывается сразу после отжатия клавиши?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102310#p102310" />
			<content type="html"><![CDATA[<p>У меня вот таким образом прописан макрос, покажите&nbsp; пожалуйста что нужно дописать, чтобы этот цикл обрывался&nbsp; сразу как отпускаю клавишу. И еще появился вопрос, как сюда дописать длительность нажатия клавиши и задержку после того как отпустишь, я так понимаю sleep это и есть задержка?<br /></p><div class="codebox"><pre><code>
sc4f::
   Loop
   {
      Send, {10
      Send, {sc41}
      Sleep, 10
      Send, {sc44}
      Sleep, 10
      Send, {sc43}
      Sleep, 10
      Send, {sc42}
      Sleep, 10
      Send, {sc41}
      Sleep, 10


      If !GetKeyState(&quot;sc4f&quot;, &quot;P&quot;)
         Break
   }
   Return
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Ox1de]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33811</uri>
			</author>
			<updated>2016-04-05T11:28:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102310#p102310</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать цикл который обрывается сразу после отжатия клавиши?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102299#p102299" />
			<content type="html"><![CDATA[<p>Я делаю так:</p><div class="codebox"><pre><code>1::
While GetKeyState(&quot;1&quot;,&quot;P&quot;) {
Send 2
If !(GetKeyState(&quot;1&quot;,&quot;P&quot;))
Break
Send 3
If !(GetKeyState(&quot;1&quot;,&quot;P&quot;))
Break
Send 4
If !(GetKeyState(&quot;1&quot;,&quot;P&quot;))
Break
Send 5
If !(GetKeyState(&quot;1&quot;,&quot;P&quot;))
Break
Send 6
If !(GetKeyState(&quot;1&quot;,&quot;P&quot;))
Break
}
Return</code></pre></div><p>Если кто то покажет как делать правильно, буду признателен.</p>]]></content>
			<author>
				<name><![CDATA[Nikva]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27416</uri>
			</author>
			<updated>2016-04-05T09:36:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102299#p102299</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать цикл который обрывается сразу после отжатия клавиши?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102287#p102287" />
			<content type="html"><![CDATA[<p><span style="color: green"><strong>Ox1de</strong>, после знаков препинания нужен отступ (пробел).<br />В названии темы должен быть префикс скриптового языка.</span></p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2016-04-05T06:47:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102287#p102287</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Как сделать цикл который обрывается сразу после отжатия клавиши?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102283#p102283" />
			<content type="html"><![CDATA[<p>Здравствуйте, собственно вопрос в шапке, нужно сделать цикл, к примеру пока держу клавишу 1, печатаются клавиши 23456,&nbsp; но,&nbsp; как только я ее отпускаю цикл должен сразу прерываться, поясню, к примеру я нажал клавишу и тут же отпустил, цикл будет идти до конца и закончится, а нужно чтобы он обрывался сразу когда клавиша отжата не доходив до конца. Как это реализовать?</p>]]></content>
			<author>
				<name><![CDATA[Ox1de]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33811</uri>
			</author>
			<updated>2016-04-05T00:09:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102283#p102283</id>
		</entry>
</feed>
