<?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=6542&amp;type=atom" />
	<updated>2011-12-20T00:07:18Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=6542</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сброс счетчика нажатием любой другой клавиши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54790#p54790" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Как сделать так, чтобы при нажатии вообще любой другой клавиши (в том числе и на мышке), счетчик сбрасывался и, в случае, если я снова нажму на эту клавишу, начинал с первого заданного значения?</p></blockquote></div><p>Когда то Teadrinker помог мне решить подобную задачу для игры. Мой скрипт&nbsp; выглядит так:</p><div class="codebox"><pre><code>$2::
If  A_PriorHotkey = 1
  {
  SetTimer, Nulling, -20
  Sleep, 40
  Send, %A_ThisHotkey%  
  }
Else If  A_PriorHotkey = 3
  {
  SetTimer, Nulling, -20
  Sleep, 40
  Send, %A_ThisHotkey%  
  }
Else If  A_PriorHotkey = 4
  {
  SetTimer, Nulling, -20
  Sleep, 40
  Send, %A_ThisHotkey%  
  }
Else If  A_PriorHotkey = 5
  {
  SetTimer, Nulling, -20
  Sleep, 40
  Send, %A_ThisHotkey%  
  }
Else If keystroke = ; если у переменной нет значения (пустое)
  {
    keystroke = 1 
    Send, 2
    SetTimer, Nulling, -4000 ; если в течении 4 секунды ничего не жать, &quot;комбо&quot; сбросится в стартовую позицию.
  } 
Else if keystroke = 1
  {
   keystroke = 2 ; присвоим переменной иное значение
    Send, 6
    SetTimer, Nulling, -4000
  }
Else if keystroke = 2
  {
    keystroke = ; очищаем переменную
    Send, 8
  }
Return


XButton2:: 
   SetTimer, Nulling, -40
   ToolTip, сброс, 400, 420 
   Sleep, 40
   ToolTip
Return


Nulling:
   keystroke =
   ToolTip сброс, 400, 430 
   Sleep, 100
   ToolTip
Return</code></pre></div><p>Если я начинаю кликать другие клавиши - происходит сброс таймеров.<br />При нажатии на дополнительную клавишу мыши происходит принудительный сброс.</p>]]></content>
			<author>
				<name><![CDATA[Raam]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25668</uri>
			</author>
			<updated>2011-12-20T00:07:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54790#p54790</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сброс счетчика нажатием любой другой клавиши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54551#p54551" />
			<content type="html"><![CDATA[<p><strong>Grey</strong>, спасибо большое, все замечательно работает!</p>]]></content>
			<author>
				<name><![CDATA[Uzbek]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27417</uri>
			</author>
			<updated>2011-12-13T10:25:40Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54551#p54551</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сброс счетчика нажатием любой другой клавиши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54535#p54535" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>#InstallMouseHook

*vk51:: ; q
*vk52:: ; r
*vk57:: ; w
   If % A_ThisHotkey&lt;&gt;Dec2Hex(GetKeyVK(A_PriorKey))
      If Dec2Hex(GetKeyVK(A_PriorKey))!=&quot;*vk20&quot;
      And Dec2Hex(GetKeyVK(A_PriorKey))!=&quot;*vk01&quot;
         bct:=rct:=act:=0
   If % A_ThisHotkey=&quot;*vk51&quot;
      SendInput, % &quot;{&quot;((act:=!act) ? &quot;Home&quot;:&quot;End&quot;)&quot;}&quot;
   Else If % A_ThisHotkey=&quot;*vk52&quot;
   {
      If !rct
      {
         SendInput, {F6}
         rct:=1
      }
      Else If rct=1
      {
         SendInput, {F7}
         rct:=2
      }
      Else If rct=2
      {
         SendInput, {F8}
         rct:=0
      }
   }
   Else If % A_ThisHotkey=&quot;*vk57&quot;
      SendInput, % &quot;{&quot;((bct:=!bct) ? &quot;Ins&quot;:&quot;Del&quot;)&quot;}&quot;
   KeyWait, % A_ThisHotkey
   Return

Dec2Hex(DecData)
{
   HexData:=0000
   DllCall(&quot;msvcrt.dll\s&quot;(A_IsUnicode ? &quot;w&quot;:&quot;&quot;)&quot;printf&quot;, &quot;Str&quot;, HexData
                                                       , &quot;Str&quot;, &quot;*vk%02x&quot;
                                                       , &quot;UInt&quot;, DecData)
   Return, HexData
}</code></pre></div><div class="quotebox"><cite>Uzbek пишет:</cite><blockquote><p>Так нет, у вас все было правильно. &quot;q&quot; — это я уже в своем исправленном варианте изменил.</p></blockquote></div><p>Угу, к чему спешка приводит... <img src="//forum.script-coding.com/img/smilies/lol.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Grey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25792</uri>
			</author>
			<updated>2011-12-12T18:50:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54535#p54535</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сброс счетчика нажатием любой другой клавиши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54534#p54534" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Uzbek пишет:</cite><blockquote><p>Как сделать так, чтобы при нажатии <strong>вообще любой другой клавиши (в том числе и на мышке)</strong>, счетчик сбрасывался и, в случае, если я снова нажму на эту клавишу, начинал с первого заданного значения?</p></blockquote></div><p>На выбор:<br />1) использовать хуки(<a href="http://forum.script-coding.com/viewtopic.php?id=6350">пример</a>).<br />2) по таймеру проверять состояние клавиатуры и мыши.<br /></p><div class="quotebox"><cite>Uzbek пишет:</cite><blockquote><p>A_IsUnicode ? &quot;w&quot;:&quot;q&quot;:&quot;r&quot;:&quot;и так далее&quot;</p></blockquote></div><p><img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Александр_]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24888</uri>
			</author>
			<updated>2011-12-12T18:46:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54534#p54534</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сброс счетчика нажатием любой другой клавиши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54516#p54516" />
			<content type="html"><![CDATA[<p><strong>Grey</strong>, в общем я сделал примерно так:</p><div class="codebox"><pre><code>*vk57::
   If % A_ThisHotkey&lt;&gt;Dec2Hex(GetKeyVK(A_PriorKey))
      bct:=0
   SendInput, % &quot;{&quot;((bct:=!bct) ? &quot;Ins&quot;:&quot;Del&quot;)&quot;}&quot;
   KeyWait, vk57
   Return
 
*vk51::
   If % A_ThisHotkey&lt;&gt;Dec2Hex(GetKeyVK(A_PriorKey))
      act:=0
   SendInput, % &quot;{&quot;((act:=!act) ? &quot;Home&quot;:&quot;End&quot;)&quot;}&quot;
   KeyWait, vk51
   Return

*vk52::
   If % A_ThisHotkey&lt;&gt;Dec2Hex(GetKeyVK(A_PriorKey))
      rct:=0
   SendInput, % &quot;{&quot;((rct:=!rct) ? &quot;F6&quot;:&quot;F7&quot;)&quot;}&quot;
   KeyWait, vk52
   Return
 
Dec2Hex(DecData)
{
   HexData:=0000
   DllCall(&quot;msvcrt.dll\s&quot;(A_IsUnicode ? &quot;w&quot;:&quot;&quot;)&quot;printf&quot;, &quot;Str&quot;, HexData
                                                       , &quot;Str&quot;, &quot;*vk%02x&quot;
                                                       , &quot;UInt&quot;, DecData)
   Return, HexData
}</code></pre></div><p>Все вроде бы работает, но появилось два важных вопроса <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p><p>1. Не получилось в третьем случае сделать ротацию трех кнопок вместо двух. Как бы туда еще F8 добавить после F6 и F7?</p><p>2. Самый важный вопрос, который вдруг всплыл после теста <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br />Можно как-то внести два исключения (пробел и лев. кнопка мыши), при использовании которых никакие счетчики не сбрасывались бы?</p>]]></content>
			<author>
				<name><![CDATA[Uzbek]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27417</uri>
			</author>
			<updated>2011-12-12T14:22:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54516#p54516</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сброс счетчика нажатием любой другой клавиши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54512#p54512" />
			<content type="html"><![CDATA[<p>Нет, это функция, она <em>перегоняет</em> десятеричное значение (получаемое от встроенной функции GetKeyVK, которая в свою очередь проверяет встроенную переменную A_PriorKey) в шестнадцатиричное с префиксом. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> Вы меня извините, я смогу помочь только вечером, ибо надо идти.</p>]]></content>
			<author>
				<name><![CDATA[Grey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25792</uri>
			</author>
			<updated>2011-12-12T10:49:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54512#p54512</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сброс счетчика нажатием любой другой клавиши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54511#p54511" />
			<content type="html"><![CDATA[<p>А. По ходу, ее не нужно дублировать.</p><p>Нужно как-то так?</p><div class="codebox"><pre><code>Dec2Hex(DecData)
{
   HexData:=0000
   DllCall(&quot;msvcrt.dll\s&quot;(A_IsUnicode ? &quot;w&quot;:&quot;q&quot;:&quot;r&quot;:&quot;и так далее&quot;)&quot;printf&quot;, &quot;Str&quot;, HexData
                                                       , &quot;Str&quot;, &quot;*vk%02x&quot;
                                                       , &quot;UInt&quot;, DecData)
   Return, HexData
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Uzbek]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27417</uri>
			</author>
			<updated>2011-12-12T10:38:09Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54511#p54511</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сброс счетчика нажатием любой другой клавиши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54510#p54510" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Хах, банальная опечатка, конечно же там должна быть <strong>w</strong> а не <strong>q</strong>.</p></blockquote></div><p>Так нет, у вас все было правильно. &quot;q&quot; — это я уже в своем исправленном варианте изменил. Т.е., я попробовал изменить код под другую клавишу (Q).</p><p>Кстати, при вставлении второго куска (уже для клавиши vk51, а не vk57) выдает ошибку Dec2Hex (Duplicate function definition).</p>]]></content>
			<author>
				<name><![CDATA[Uzbek]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27417</uri>
			</author>
			<updated>2011-12-12T10:35:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54510#p54510</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сброс счетчика нажатием любой другой клавиши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54508#p54508" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Uzbek пишет:</cite><blockquote><p>DllCall(&quot;msvcrt.dll\s&quot;(A_IsUnicode ? <strong>&quot;w&quot;</strong></p></blockquote></div><p>Хах, банальная опечатка, конечно же там должна быть <strong>w</strong> а не <strong>q</strong>. Я проверяю скрипты все после запуска прямо в редакторе, где их и пишу... <img src="//forum.script-coding.com/img/smilies/lol.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Grey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25792</uri>
			</author>
			<updated>2011-12-12T10:20:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54508#p54508</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сброс счетчика нажатием любой другой клавиши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54506#p54506" />
			<content type="html"><![CDATA[<p>Проверил ваш код. Работает великолепно!</p>]]></content>
			<author>
				<name><![CDATA[Uzbek]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27417</uri>
			</author>
			<updated>2011-12-12T10:04:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54506#p54506</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сброс счетчика нажатием любой другой клавиши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54505#p54505" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Луше и быстрее будет, если я буду знать все клавиши и то, что они должны делать, и у Вас будет стартовый пример, для дальнейших разработок. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p></blockquote></div><p>Без сомнений, это точно будет быстрее и лучше <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p><p>Ну, вот vk51 (Q) — поочередное нажатие Home, End</p><p>vk52 — F6, F7, F8</p><p>И такой же сброс, конечно же.</p><div class="quotebox"><blockquote><p>Ну как-бы эта W (*vk57) изначально не моя, и пом, где внизу?</p></blockquote></div><p>DllCall(&quot;msvcrt.dll\s&quot;(A_IsUnicode ? <strong>&quot;w&quot;</strong></p>]]></content>
			<author>
				<name><![CDATA[Uzbek]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27417</uri>
			</author>
			<updated>2011-12-12T10:01:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54505#p54505</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сброс счетчика нажатием любой другой клавиши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54504#p54504" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Uzbek пишет:</cite><blockquote><p>...надо будет поправить примерно так?</p></blockquote></div><p>Луше и быстрее будет, если я буду знать все клавиши и то, что они должны делать, и у Вас будет стартовый пример, для дальнейших разработок. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br /></p><div class="quotebox"><cite>Uzbek пишет:</cite><blockquote><p>Сомнение вызывает ваша &quot;w&quot; внизу</p></blockquote></div><p>Ну как-бы эта W (*vk57) изначально не моя, и пом, где внизу?</p>]]></content>
			<author>
				<name><![CDATA[Grey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25792</uri>
			</author>
			<updated>2011-12-12T09:52:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54504#p54504</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сброс счетчика нажатием любой другой клавиши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54500#p54500" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Ваш <em>идеальный вариант</em> готов</p></blockquote></div><p>Спасибо огромное, пойду тестить.</p><p>А для других счетчиков (коих у меня много) надо будет поправить примерно так? (Например, для vk51, и для других клавиш.)</p><div class="codebox"><pre><code>*vk51::
   If % A_ThisHotkey&lt;&gt;Dec2Hex(GetKeyVK(A_PriorKey))
      bct:=0
   SendInput, % &quot;{&quot;((act:=!act) ? &quot;Home&quot;:&quot;End&quot;:&quot;PgUp&quot;)&quot;}&quot;
   KeyWait, vk51
   Return
 
Dec2Hex(DecData)
{
   HexData:=0000
   DllCall(&quot;msvcrt.dll\s&quot;(A_IsUnicode ? &quot;q&quot;:&quot;&quot;)&quot;printf&quot;, &quot;Str&quot;, HexData
                                                       , &quot;Str&quot;, &quot;*vk%02x&quot;
                                                       , &quot;UInt&quot;, DecData)
   Return, HexData
}</code></pre></div><p>Если что, я чисто интуитивно тут в потемках шарюсь. Сомнение вызывает ваша &quot;w&quot; внизу — это клавиша, или это какая-то другая переменная? Я ее заменил на &quot;q&quot;, потому что решил, что это клавиша <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Uzbek]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27417</uri>
			</author>
			<updated>2011-12-12T09:32:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54500#p54500</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сброс счетчика нажатием любой другой клавиши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54498#p54498" />
			<content type="html"><![CDATA[<p>Ваш <em>идеальный вариант</em> готов:</p><div class="codebox"><pre><code>*vk57::
   If % A_ThisHotkey&lt;&gt;Dec2Hex(GetKeyVK(A_PriorKey))
      bct:=0
   SendInput, % &quot;{&quot;((bct:=!bct) ? &quot;Ins&quot;:&quot;Del&quot;)&quot;}&quot;
   KeyWait, vk57
   Return

Dec2Hex(DecData)
{
   HexData:=0000
   DllCall(&quot;msvcrt.dll\s&quot;(A_IsUnicode ? &quot;w&quot;:&quot;&quot;)&quot;printf&quot;, &quot;Str&quot;, HexData
                                                       , &quot;Str&quot;, &quot;*vk%02x&quot;
                                                       , &quot;UInt&quot;, DecData)
   Return, HexData
}</code></pre></div><div class="quotebox"><cite>Uzbek пишет:</cite><blockquote><p>...как правильно прописать сброс нескольких счетчиков?</p></blockquote></div><div class="codebox"><pre><code>~LButton::bct:=act:=cct:=dct:=0</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Grey]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25792</uri>
			</author>
			<updated>2011-12-12T09:05:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54498#p54498</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Сброс счетчика нажатием любой другой клавиши]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=54495#p54495" />
			<content type="html"><![CDATA[<p>Ваш вариант с LButton тоже, в принципе, пойдет.<br />Скажите, а как правильно прописать сброс нескольких счетчиков? Не только bct, а еще и act, cct, dct и так далее.</p>]]></content>
			<author>
				<name><![CDATA[Uzbek]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27417</uri>
			</author>
			<updated>2011-12-12T08:14:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=54495#p54495</id>
		</entry>
</feed>
