<?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="https://forum.script-coding.com/extern.php?action=feed&amp;tid=15685&amp;type=atom" />
	<updated>2020-09-22T01:01:37Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=15685</id>
		<entry>
			<title type="html"><![CDATA[Глобальный хук клавиатуры.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=142244#p142244" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[mkone112]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40951</uri>
			</author>
			<updated>2020-09-22T01:01:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=142244#p142244</id>
		</entry>
</feed>
