<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=12144</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=12144&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Прерывание в скрипте с "while GetKeyState"».]]></description>
		<lastBuildDate>Sat, 12 Nov 2016 19:13:13 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=109099#p109099</link>
			<description><![CDATA[<p><strong>teadrinker</strong><br />Вечер добрый. Это именно то, что я и хотел. Благодарю Вас за помощь.</p>]]></description>
			<author><![CDATA[null@example.com (Hyperspeed)]]></author>
			<pubDate>Sat, 12 Nov 2016 19:13:13 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=109099#p109099</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=109092#p109092</link>
			<description><![CDATA[<div class="codebox"><pre><code>XButton2 := [ [5, 150], [21, 130], [14, 150], [5, 135], [21, 150], [5, 0], [3, 130], [21, 130], [5, 130], [21, 100], [13, 100], [5, 130], [14, 150], [5, 135], [21, 250] ]
sc2 := [ [0, 300], [2, 400], [21, 800], [&quot;2f&quot;, 350], [5, 700], [14, 850], [13, 145], [5, 0] ]
sc4 := [ [0, 300], [4, 1500], [&quot;2f&quot;, 350], [5, 700], [14, 850], [13, 145], [5, 0] ]
flag := []

XButton2:: flag[1] := false, SendKeys(A_ThisHotkey, true, flag)

sc2::
sc4:: flag[1] := true, SendKeys(A_ThisHotkey, false, flag)

SendKeys(key, var, flag)  {
   while GetKeyState(key, &quot;P&quot;)  {
      for k, v in %key%  {
         if v[1]
            Send, % &quot;{sc&quot; . v[1] . &quot;}&quot;
         if v[2]
            Sleep, v[2]
         if var &amp;&amp; flag[1]
            break
      }
   }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sat, 12 Nov 2016 03:20:08 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=109092#p109092</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=109091#p109091</link>
			<description><![CDATA[<p>Какая ещё каша? При нажатии xButton2:: должны циклично выполняться действия в фигурных скобках.<br />По нажатию sc2:: или sc4:: эти действия доходят до конца и более не повторяются. А Вы хотели разорвать цикл на полпути? Любой прерванный поток возобновляется.</p>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Fri, 11 Nov 2016 22:15:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=109091#p109091</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=109088#p109088</link>
			<description><![CDATA[<p><strong>ypppu</strong><br />Благодарю за вариант, но увы работает как мой старый. Наверное следовало уточнить, что у меня просто набор кнопок там где &quot;скрипт. Вставлять&nbsp; 1 и 3 нужно в случайное время при надобности и в итоге получается так сказать каша.</p><p>Вот собственно весь скрипт:</p><div class="codebox"><pre><code> xButton2:: 
 while GetKeyState(&quot;xButton2&quot;, &quot;P&quot;)
 {
  Send {sc5}
	Sleep 150
  Send {sc21}
	Sleep 130
  Send {sc14}
	Sleep 150
  Send {sc5}
	Sleep 135
  Send {sc21}
	Sleep 150
  Send {sc5}
  Send {sc3}
	Sleep 130
  Send {sc21}
	Sleep 130
  Send {sc5}
	Sleep 130
  Send {sc21}
	Sleep 100
  Send {sc13}
	Sleep 100
  Send {sc5}
	Sleep 130
  Send {sc14}
	Sleep 150
  Send {sc5}
	Sleep 135
  Send {sc21}
	Sleep 250
 }
 Return

sc2::
 while GetKeyState(&quot;sc2&quot;, &quot;P&quot;)
{
	Sleep 300
  Send {sc2}
	Sleep 400
  Send {sc21}
	Sleep 800
  Send {vk56}
	Sleep 350
  Send {sc5}
	Sleep 700
  Send {sc14}
	Sleep 850
  Send {sc13}
	Sleep 145
  Send {sc5}
}
Return

sc4::
 while GetKeyState(&quot;sc4&quot;, &quot;P&quot;)
{
	Sleep 300
  Send {sc4}
	Sleep 1500
  Send {vk56}
	Sleep 350
  Send {sc5}
	Sleep 700
  Send {sc14}
	Sleep 850
  Send {sc13}
	Sleep 145
  Send {sc5}
}
Return </code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Hyperspeed)]]></author>
			<pubDate>Fri, 11 Nov 2016 20:14:40 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=109088#p109088</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=109087#p109087</link>
			<description><![CDATA[<div class="codebox"><pre><code>xButton2::
flag := 1
While GetKeyState(&quot;xButton2&quot;, &quot;P&quot;)
{
If flag = 0
Break
;скрипт
}
Return

sc2::
flag := 0
While GetKeyState(&quot;sc2&quot;, &quot;P&quot;)
{
;скрипт
}
Return

sc4::
flag := 0
While GetKeyState(&quot;sc4&quot;, &quot;P&quot;)
{
;скрипт
}
Return </code></pre></div>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Fri, 11 Nov 2016 17:18:43 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=109087#p109087</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=109081#p109081</link>
			<description><![CDATA[<p><strong>ypppu</strong><br />Вечер добрый. Подскажите, что если в скрипте 2-3 действующие кнопки? Можно ли сделать чтоб прерывая к примеру первый цикл второй кнопкой после завершения действия с второй кнопки скрипт не продолжал прерванный цикл с первой?</p><p>Использую такой вариант как ниже. Он прерывает текущий при нажатии другой кнопки и выполняет его, но после завершает старый. Подскажите пожалуйста каким образом его заставить сбрасывать либо начинать с нуля старый не завершая его? Прерываю только тот, что с xButton2.</p><div class="codebox"><pre><code>xButton2:: 
 while GetKeyState(&quot;xButton2&quot;, &quot;P&quot;)
 {
&quot;скрипт
 }
 Return

sc2::
 while GetKeyState(&quot;sc2&quot;, &quot;P&quot;)
{
&quot;скрипт
}
Return

sc4::
 while GetKeyState(&quot;sc4&quot;, &quot;P&quot;)
{
&quot;скрипт
}
Return </code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Hyperspeed)]]></author>
			<pubDate>Fri, 11 Nov 2016 15:43:27 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=109081#p109081</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=109079#p109079</link>
			<description><![CDATA[<p>Можно поставить в тело цикла некое условие. И, если оно будет выполнено, то выполнить команду <em>Break</em> (прервать цикл). Сбросить в начало скрипт можно командой <em>Reload</em>. Если нужно начать заново только цикл, то есть команда <em>GoTo</em>.</p>]]></description>
			<author><![CDATA[null@example.com (ypppu)]]></author>
			<pubDate>Fri, 11 Nov 2016 13:29:53 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=109079#p109079</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=109077#p109077</link>
			<description><![CDATA[<p>День добрый. Подскажите есть ли способ прервать или сбросить на начало скрипт с &quot;while GetKeyState&quot; в любой момент не завершая полный цикл? <br /></p><div class="codebox"><pre><code> sc2::
 while GetKeyState(&quot;sc2&quot;, &quot;P&quot;)
{
&quot;скрипт
}
Return </code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Hyperspeed)]]></author>
			<pubDate>Fri, 11 Nov 2016 12:06:11 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=109077#p109077</guid>
		</item>
	</channel>
</rss>
