<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=12144&amp;type=atom" />
	<updated>2016-11-12T19:13:13Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=12144</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109099#p109099" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Вечер добрый. Это именно то, что я и хотел. Благодарю Вас за помощь.</p>]]></content>
			<author>
				<name><![CDATA[Hyperspeed]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34312</uri>
			</author>
			<updated>2016-11-12T19:13:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109099#p109099</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109092#p109092" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-11-12T03:20:08Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109092#p109092</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109091#p109091" />
			<content type="html"><![CDATA[<p>Какая ещё каша? При нажатии xButton2:: должны циклично выполняться действия в фигурных скобках.<br />По нажатию sc2:: или sc4:: эти действия доходят до конца и более не повторяются. А Вы хотели разорвать цикл на полпути? Любой прерванный поток возобновляется.</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2016-11-11T22:15:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109091#p109091</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109088#p109088" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Hyperspeed]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34312</uri>
			</author>
			<updated>2016-11-11T20:14:40Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109088#p109088</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109087#p109087" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2016-11-11T17:18:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109087#p109087</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109081#p109081" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Hyperspeed]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34312</uri>
			</author>
			<updated>2016-11-11T15:43:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109081#p109081</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109079#p109079" />
			<content type="html"><![CDATA[<p>Можно поставить в тело цикла некое условие. И, если оно будет выполнено, то выполнить команду <em>Break</em> (прервать цикл). Сбросить в начало скрипт можно командой <em>Reload</em>. Если нужно начать заново только цикл, то есть команда <em>GoTo</em>.</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2016-11-11T13:29:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109079#p109079</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Прерывание в скрипте с "while GetKeyState"]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=109077#p109077" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Hyperspeed]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34312</uri>
			</author>
			<updated>2016-11-11T12:06:11Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=109077#p109077</id>
		</entry>
</feed>
