<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; Глобальный хук клавиатуры.]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=15685</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=15685&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «Глобальный хук клавиатуры.».]]></description>
		<lastBuildDate>Tue, 22 Sep 2020 01:01:37 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Глобальный хук клавиатуры.]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=142244#p142244</link>
			<description><![CDATA[<p>Как написать скрипт отлавливающий все нажатия, и добавляющий их в массив?<br />Мой криво работающий код:</p><div class="codebox"><pre><code>#SingleInstance force
#SingleInstance, force
#NoEnv
Process, Priority, , H
SetBatchLines, -1
global key_seq := []
global pressed_keys := {}


ih := InputHook(&quot;L0&quot;)
ih.KeyOpt(&quot;{All}&quot;, &quot;NS&quot;)
ih.OnKeyDown := Func(&quot;OnKey&quot;).bind(&quot;Down&quot;)
ih.OnKeyUp := Func(&quot;OnKey&quot;).bind(&quot;Up&quot;)
ih.OnEnd := Func(&quot;OnEnd&quot;)
ih.Start()
return

OnKey(direction, InputHook, vk) {
	key_code := Format(&quot;vk{:X}&quot;, vk)
	key_name := GetKeyName(key_code)
	key_with_direction := &quot;{&quot; . key_name . &quot; &quot; . direction . &quot;}&quot;
	i := key_seq.MaxIndex()
   
	if (direction == &quot;Down&quot; and key_with_direction != key_seq[i] and not pressed_keys[key_name])
	{
		key_seq.Push(key_with_direction)
		pressed_keys[key_name] := true
	}
	else if (direction == &quot;Up&quot;)
	{
		key_seq.Push(key_with_direction)
		pressed_keys[key_name] := false
	}
	
	InputHook.Stop()
	Send {%key_code%  %direction%}
	i := key_seq.MaxIndex()
	tooltip % key_seq[i-2] . key_seq[i-1] . key_seq[i]
	
}

OnEnd(InputHook) {
	InputHook.Start()
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (mkone112)]]></author>
			<pubDate>Tue, 22 Sep 2020 01:01:37 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=142244#p142244</guid>
		</item>
	</channel>
</rss>
