<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; Непрерывное воспроизведение при зажатом модификаторе]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=12014&amp;type=atom" />
	<updated>2016-09-16T20:28:22Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=12014</id>
		<entry>
			<title type="html"><![CDATA[Re: Непрерывное воспроизведение при зажатом модификаторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=107783#p107783" />
			<content type="html"><![CDATA[<p>Сможет ли кто-то указать на возможные ошибки в несовпадениях функции кода с windows 10? <br />У меня так и не вышло сделать его работоспособным.</p><p>p.s. Этот код,..:<br /></p><div class="codebox"><pre><code>vkArray := [&quot;31&quot;, &quot;32&quot;, &quot;34&quot;, &quot;35&quot;, &quot;36&quot;, &quot;43&quot;, &quot;45&quot;, &quot;46&quot;, &quot;47&quot;, &quot;51&quot;, &quot;52&quot;, &quot;54&quot;, &quot;56&quot;, &quot;58&quot;, &quot;5A&quot;]  ; vk-коды нужных клавиш
dalay := 50

for k, v in vkArray  {
   Hotkey, % &quot;$vk&quot; . v, handler, On
   Hotkey, % &quot;$^vk&quot; . v, handler, On
   Hotkey, % &quot;$+vk&quot; . v, handler, On
   Hotkey, % &quot;$!vk&quot; . v, handler, On
}
Return

handler:
   key := RegExReplace(A_ThisHotkey, &quot;\$([\^+!])?(v.*)&quot;, &quot;$1{$2}&quot;)
   While GetKeyState(SubStr(A_ThisHotkey, -3), &quot;P&quot;)  {
      SendInput, % key
      Sleep, dalay
   }
   Return</code></pre></div><p>.., вполне себе хороший вариант, только как я писал выше, есть небольшой баг (не удобство) - <em>при последовательном зажимании кнопок, к примеру, 1-2-3, после 3-ей кнопки и началом повторения круга с кнопки 1 происходит лаг в течении ~0,5 сек.<br />Ход из 3-ёх последовательных нажиманий происходит нормально, на 4-ый лаг, следовательно, пользоваться &quot;автоспамом&quot; не совсем удобно.</em><br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Видео на данный эффект</div><div class="fancy_spoiler"><p><a href="https://youtu.be/WMtV0GAXEX4">https://youtu.be/WMtV0GAXEX4</a></p></div></div><p>Или же, как можно приделать данную функцию:<br /></p><div class="codebox"><pre><code>for k, v in vkArray  {
   Hotkey, % &quot;$vk&quot; . v, handler, On
   Hotkey, % &quot;$^vk&quot; . v, handler, On
   Hotkey, % &quot;$+vk&quot; . v, handler, On
   Hotkey, % &quot;$!vk&quot; . v, handler, On
}
Return</code></pre></div><p>К этому коду:<br /></p><div class="codebox"><pre><code>#MaxHotkeysPerInterval 1000
SetBatchLines -1
SetKeyDelay -1
SetTimer t,1
Arr := []

Arr[&quot;$vk31&quot;] :=  {Send:&quot;{vk31}&quot; , Time:50 }
Arr[&quot;$vk31&quot;] :=  {Send:&quot;{vk31}&quot; , Time:50 }
Arr[&quot;$vk32&quot;] :=  {Send:&quot;{vk32}&quot; , Time:50 }
Arr[&quot;$vk33&quot;] :=  {Send:&quot;{vk33}&quot; , Time:50 }
Arr[&quot;$vk34&quot;] :=  {Send:&quot;{vk34}&quot; , Time:50 }
Arr[&quot;$vk35&quot;] :=  {Send:&quot;{vk35}&quot; , Time:50 }
Arr[&quot;$vk36&quot;] :=  {Send:&quot;{vk36}&quot; , Time:50 }
Arr[&quot;$vk46&quot;] :=  {Send:&quot;{vk46}&quot; , Time:50 }
Arr[&quot;$vk47&quot;] :=  {Send:&quot;{vk47}&quot; , Time:50 }
Arr[&quot;$vk51&quot;] :=  {Send:&quot;{vk51}&quot; , Time:50 }
Arr[&quot;$vk43&quot;] :=  {Send:&quot;{vk43}&quot; , Time:50 }
Arr[&quot;$vk45&quot;] :=  {Send:&quot;{vk45}&quot; , Time:50 }
Arr[&quot;$vk54&quot;] :=  {Send:&quot;{vk54}&quot; , Time:50 }
Arr[&quot;$vk54&quot;] :=  {Send:&quot;{vk54}&quot; , Time:50 }
Arr[&quot;$vk56&quot;] :=  {Send:&quot;{vk56}&quot; , Time:50 }
Arr[&quot;$vk5A&quot;] :=  {Send:&quot;{vk5A}&quot; , Time:50 }
Arr[&quot;$vk58&quot;] :=  {Send:&quot;{vk58}&quot; , Time:50 }
Arr[&quot;$vk52&quot;] :=  {Send:&quot;{vk52}&quot; , Time:50 }

for i, k in Arr
    Hotkey %i%,pressing,On
pressing:
return
t:
for i, k in Arr
    if GetKeyState((RegExMatch(i,&quot;(vk..)&quot;,hk)+&quot;&quot;) hk1,&quot;p&quot;)
    and (A_TickCount &gt; Arr[i].Timer) &amp;&amp; (Arr[i].Timer := A_TickCount + k.Time)
        Send % k.Send
return

vk2D::
Suspend
Pause,,1
return</code></pre></div><p>Для того, чтобы он работал с <strong>модификаторами</strong>.</p>]]></content>
			<author>
				<name><![CDATA[kna1703]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=33223</uri>
			</author>
			<updated>2016-09-16T20:28:22Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=107783#p107783</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Непрерывное воспроизведение при зажатом модификаторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=107774#p107774" />
			<content type="html"><![CDATA[<p>А, ясно. В моём коде используется клавиатурный хук, в десятке, наверно, его что-нибудь блокирует, UAC, или что-то такое, я не разбираюсь, у меня 7. Попробуйте отключить UAC, или запустить код от администратора.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-09-16T13:19:41Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=107774#p107774</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Непрерывное воспроизведение при зажатом модификаторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=107772#p107772" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Windows 10 Pro 64-разрядная <em>build 10586</em> (с обновлениями)<br />Autohotkey <em>version v1.1.24.01</em></p><p>p.s. То же самое и дома происходит. Хотя там такая же ОСь и версия Autohotkey&#039;я.</p>]]></content>
			<author>
				<name><![CDATA[kna1703]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=33223</uri>
			</author>
			<updated>2016-09-16T12:37:36Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=107772#p107772</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Непрерывное воспроизведение при зажатом модификаторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=107771#p107771" />
			<content type="html"><![CDATA[<p>А какая ОС и какая версия AHK?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-09-16T12:13:37Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=107771#p107771</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Непрерывное воспроизведение при зажатом модификаторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=107770#p107770" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Записал видео подтверждение своих действий.<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;Ссылка на видео</div><div class="fancy_spoiler"><p><a href="https://youtu.be/7h-wMaNMVGE">https://youtu.be/7h-wMaNMVGE</a></p></div></div>]]></content>
			<author>
				<name><![CDATA[kna1703]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=33223</uri>
			</author>
			<updated>2016-09-16T11:04:59Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=107770#p107770</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Непрерывное воспроизведение при зажатом модификаторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=107768#p107768" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>kna1703 пишет:</cite><blockquote><p>кнопка &quot;ESC&quot; выключает скрипт</p></blockquote></div><p>Так и должно быть, там в конце горячая клавиша, можно убрать. Просто запустите скрипт и откройте блокнот (Notepad).</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-09-16T08:50:37Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=107768#p107768</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Непрерывное воспроизведение при зажатом модификаторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=107767#p107767" />
			<content type="html"><![CDATA[<p>Кто-нибудь, проверьте пожалуйста код <strong>teadrinker</strong><em>&#039;а</em>, а то у меня совершенно не выходит увидеть его работоспособность + кнопка &quot;ESC&quot; выключает скрипт.</p>]]></content>
			<author>
				<name><![CDATA[kna1703]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=33223</uri>
			</author>
			<updated>2016-09-16T08:37:19Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=107767#p107767</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Непрерывное воспроизведение при зажатом модификаторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=107760#p107760" />
			<content type="html"><![CDATA[<p>У меня работает, если проверять в блокноте.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-09-15T21:21:23Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=107760#p107760</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Непрерывное воспроизведение при зажатом модификаторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=107759#p107759" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Кнопки из добавленного списка не нажимаются, то есть не происходит ничего.</p>]]></content>
			<author>
				<name><![CDATA[kna1703]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=33223</uri>
			</author>
			<updated>2016-09-15T21:04:37Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=107759#p107759</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Непрерывное воспроизведение при зажатом модификаторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=107744#p107744" />
			<content type="html"><![CDATA[<p><strong>kna1703</strong>, ещё так можно попробовать:<br /></p><div class="codebox"><pre><code>SetBatchLines, -1
delay := 50
vkArray := [delay, &quot;31&quot;, &quot;32&quot;, &quot;34&quot;, &quot;35&quot;, &quot;36&quot;, &quot;43&quot;, &quot;45&quot;, &quot;46&quot;, &quot;47&quot;, &quot;51&quot;, &quot;52&quot;, &quot;54&quot;, &quot;56&quot;, &quot;58&quot;, &quot;5A&quot;]  ; vk-коды нужных клавиш, не должно быть модификаторов

DllCall(&quot;SetWindowsHookEx&quot;
   , Int, WH_KEYBOARD_LL := 13
   , Ptr, RegisterCallback(&quot;LowLevelKeyboardProc&quot;, &quot;Fast&quot;, 3, ptr := Object(vkArray))
   , Ptr, DllCall(&quot;GetModuleHandle&quot;, UInt, 0, Ptr)
   , UInt, 0, Ptr)
ObjRelease(ptr)
Return

LowLevelKeyboardProc(nCode, wParam, lParam)
{
   static LLKHF_INJECTED := 0x10, keyArr := {}
      , oMsg := {0x100: &quot;WM_KEYDOWN&quot;, 0x101: &quot;WM_KEYUP&quot;}
   
   msg := wParam   
   vk := NumGet(lParam + 0, &quot;UInt&quot;)
   flags := NumGet(lParam + 8, &quot;UInt&quot;)
   INJECTED := (flags &amp; LLKHF_INJECTED) &gt;&gt; 4
   
   for k, v in Object(A_EventInfo)  {
      if (k = 1)  {
         delay := v
         continue
      }
      if ( vk = Format(&quot;{:u}&quot;, &quot;0x&quot; . v) &amp;&amp; !INJECTED )  {
         if (oMsg[msg] = &quot;WM_KEYUP&quot;)  {
            keyArr.Delete(v)
            handler := Func(&quot;Handler&quot;).Bind(v, false)
            SetTimer, % handler, -10
         }
         else if !keyArr.HasKey(v)  {
            keyArr[v] := true
            handler := Func(&quot;Handler&quot;).Bind(v, true, delay)
            SetTimer, % handler, -10
         }
         Return true
      }
   }
   Return DllCall(&quot;CallNextHookEx&quot;, Ptr, 0, Int, nCode, Ptr, wParam, Ptr, lParam)
}
   
Handler(vk, mode, delay := &quot;&quot;)  {
   static timers := {}
   if mode  {
      timer := Func(&quot;Sender&quot;).Bind(vk)
      timers[vk] := timer
      Sender(vk)
      SetTimer, % timer, % delay
   }
   else  {
      timer := timers[vk]
      SetTimer, % timer, Delete
   }
}
      
Sender(vk)  {
   for k, v in { Alt: &quot;!&quot;, Ctrl: &quot;^&quot;, Shift: &quot;+&quot; }
      if GetKeyState(k, &quot;P&quot;)
         modifier .= v
   
   SendPlay, % modifier . &quot;{vk&quot; vk &quot;}&quot;
}
   
Esc::ExitApp</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-09-15T16:42:33Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=107744#p107744</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Непрерывное воспроизведение при зажатом модификаторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=107741#p107741" />
			<content type="html"><![CDATA[<p>Огромное спасибо! Очень близко к идеалу!</p><p>Заметил ещё одну маленькую особенность у вашего варианта кода: при последовательном зажимании кнопок, к примеру, 1-2-3, после 3-ей кнопки и началом повторения круга с кнопки 1 происходит лаг в течении ~0,5 сек.<br />Ход из 3-ёх последовательных нажиманий происходит нормально, на 4-ый лаг, следовательно, пользоваться &quot;автоспамом&quot; не совсем удобно.</p>]]></content>
			<author>
				<name><![CDATA[kna1703]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=33223</uri>
			</author>
			<updated>2016-09-15T14:11:35Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=107741#p107741</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Непрерывное воспроизведение при зажатом модификаторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=107740#p107740" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>kna1703 пишет:</cite><blockquote><p>Не выходит с модификатором, к примеру &quot;shift&quot;.</p></blockquote></div><p>Так тогда можно:<br /></p><div class="codebox"><pre><code>vkArray := [&quot;31&quot;, &quot;32&quot;, &quot;34&quot;, &quot;35&quot;, &quot;36&quot;, &quot;43&quot;, &quot;45&quot;, &quot;46&quot;, &quot;47&quot;, &quot;51&quot;, &quot;52&quot;, &quot;54&quot;, &quot;56&quot;, &quot;58&quot;, &quot;5A&quot;]  ; vk-коды нужных клавиш
dalay := 50

for k, v in vkArray  {
   Hotkey, % &quot;$vk&quot; . v, handler, On
   Hotkey, % &quot;$^vk&quot; . v, handler, On
   Hotkey, % &quot;$+vk&quot; . v, handler, On
   Hotkey, % &quot;$!vk&quot; . v, handler, On
}
Return

handler:
   key := RegExReplace(A_ThisHotkey, &quot;\$([\^+!])?(v.*)&quot;, &quot;$1{$2}&quot;)
   While GetKeyState(SubStr(A_ThisHotkey, -3), &quot;P&quot;)  {
      SendInput, % key
      Sleep, dalay
   }
   Return</code></pre></div><p>С «одновременно» подумаю. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-09-15T13:48:37Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=107740#p107740</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Непрерывное воспроизведение при зажатом модификаторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=107739#p107739" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Не выходит с модификатором, к примеру &quot;shift&quot;. <br />Вместо &quot;!&quot; пишется &quot;1&quot;.</p><p>И ещё в таком варианте не получается выводить <strong>одновременно</strong> несколько разных символов при зажатии соответствующих кнопок. <em>(Зажимаешь 1 - пишется единица, потом не отпуская нажимаешь на 2 - пишется 2, но единица перестаёт. p.s. По стандарту в &quot;Windows&quot; точно так же, но при возможности хотелось бы расширить границы возможного.)</em></p>]]></content>
			<author>
				<name><![CDATA[kna1703]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=33223</uri>
			</author>
			<updated>2016-09-15T13:24:36Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=107739#p107739</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Непрерывное воспроизведение при зажатом модификаторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=107738#p107738" />
			<content type="html"><![CDATA[<p><strong>kna1703</strong>, так?<br /></p><div class="codebox"><pre><code>vkArray := [&quot;31&quot;, &quot;32&quot;, &quot;34&quot;, &quot;35&quot;, &quot;36&quot;, &quot;43&quot;, &quot;45&quot;, &quot;46&quot;, &quot;47&quot;, &quot;51&quot;, &quot;52&quot;, &quot;54&quot;, &quot;56&quot;, &quot;58&quot;, &quot;5A&quot;]  ; vk-коды нужных клавиш
delay := 50

for k, v in vkArray
   Hotkey, % &quot;*$vk&quot; . v, handler, On
Return

handler:
   While GetKeyState(key := SubStr(A_ThisHotkey, -3), &quot;P&quot;)  {
      SendInput, {%key%}
      Sleep, delay
   }
   Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-09-15T13:16:05Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=107738#p107738</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Непрерывное воспроизведение при зажатом модификаторе]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=107726#p107726" />
			<content type="html"><![CDATA[<p>-del</p>]]></content>
			<author>
				<name><![CDATA[Indomito]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27285</uri>
			</author>
			<updated>2016-09-15T11:48:13Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=107726#p107726</id>
		</entry>
</feed>
