<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[TastaturHook zu schnell (?)]]></title><description><![CDATA[<p>tagchen zusammen,<br />
ich benutze einen Tastaturhook, was auch wunderbar funktioniert, allerdings zu gut. Denn wenn ich zB 'a' antippe, dann schreibt er 'aa' in die Variable. Bei allen anderen Buchstaben genauso. Ich dachte erst, das könnte dadran liegen, dass die Tasten so schnell abgefragt werden, dass man sie noch nicht losgelassen hat, aber auch mit einem Sleep innerhalb der Funktion gibts doppelte Buchstaben. Da ich nicht genau weiß, was ich jetzt noch machen könnte, poste ich einfach mal den Code. oshi.pGui-&gt; etc sind Klassen, die hier den Rahmen sprengen würden und auch nichts mit dem Problem zu tun haben, weswegen ich sie weglasse.</p>
<pre><code class="language-cpp">char kleinbuchstaben[] = &quot;abcdefghijklmnopqrstuvwxyz&quot;;
char grossbuchstaben[] = &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;;
char zahlen[] = &quot;0123456789&quot;;
//---------------------------------------------------------------------------
LRESULT CALLBACK KeyboardHook(int code, WPARAM wParam, LPARAM lParam)
{
	if(Cvars.x == 0)
		return CallNextHookEx(oshi.pGui-&gt;KeyHookHandle, code, wParam, lParam);

	if(oshi.pGui-&gt;CheckKey(code, wParam, lParam))
		return TRUE;

	return CallNextHookEx(oshi.pGui-&gt;KeyHookHandle, code, wParam, lParam);
}
//---------------------------------------------------------------------------
bool Gui::CheckKey(int code, WPARAM wParam, LPARAM lParam)
{
	if(!oshi.pGui-&gt;guian)
		return false;
	//Sleep(200);
	switch (wParam)
	{
		case VK_RETURN:
		{
			if(oshi.pGui-&gt;CommandLine.empty())
				return true;
			text.push_back(oshi.pGui-&gt;CommandLine);
			oshi.pGui-&gt;CommandLine.clear();
			return true;
		}
		case VK_SPACE:
		{
			oshi.pGui-&gt;CommandLine += ' ';
			return true;
		}
		case VK_BACK:
		{
			if(oshi.pGui-&gt;CommandLine.length() &gt; 0)
				oshi.pGui-&gt;CommandLine.erase(oshi.pGui-&gt;CommandLine.length() - 1, oshi.pGui-&gt;CommandLine.length());			
			return true;
		}
		default:
		{	
			if(wParam &gt; 0x40 &amp;&amp; wParam &lt; 0x5B)
			{
				if(GetAsyncKeyState(VK_SHIFT))
					oshi.pGui-&gt;CommandLine += grossbuchstaben[wParam - 0x41];
				else
					oshi.pGui-&gt;CommandLine += kleinbuchstaben[wParam - 0x41];
				return true;
			}
			else if(wParam &gt;= 0x30 &amp;&amp; wParam &lt;= 39)
			{
				if(GetAsyncKeyState(VK_SHIFT))
					return false;
				else
					oshi.pGui-&gt;CommandLine += zahlen[wParam - 0x30];
				return true;
			}
			else
			{
				char szKeyname[10];
				if(GetKeyNameText(lParam, szKeyname, 10))
				{
					if(strlen(szKeyname) == 1)
					{
						oshi.pGui-&gt;CommandLine += szKeyname;
					}
					return true;
				}
			}
		}
	}
	return false;
}
//---------------------------------------------------------------------------
</code></pre>
<p>greetz KN4CK3R</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/209728/tastaturhook-zu-schnell</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 06:45:39 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/209728.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 02 Apr 2008 17:12:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to TastaturHook zu schnell (?) on Wed, 02 Apr 2008 17:12:25 GMT]]></title><description><![CDATA[<p>tagchen zusammen,<br />
ich benutze einen Tastaturhook, was auch wunderbar funktioniert, allerdings zu gut. Denn wenn ich zB 'a' antippe, dann schreibt er 'aa' in die Variable. Bei allen anderen Buchstaben genauso. Ich dachte erst, das könnte dadran liegen, dass die Tasten so schnell abgefragt werden, dass man sie noch nicht losgelassen hat, aber auch mit einem Sleep innerhalb der Funktion gibts doppelte Buchstaben. Da ich nicht genau weiß, was ich jetzt noch machen könnte, poste ich einfach mal den Code. oshi.pGui-&gt; etc sind Klassen, die hier den Rahmen sprengen würden und auch nichts mit dem Problem zu tun haben, weswegen ich sie weglasse.</p>
<pre><code class="language-cpp">char kleinbuchstaben[] = &quot;abcdefghijklmnopqrstuvwxyz&quot;;
char grossbuchstaben[] = &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;;
char zahlen[] = &quot;0123456789&quot;;
//---------------------------------------------------------------------------
LRESULT CALLBACK KeyboardHook(int code, WPARAM wParam, LPARAM lParam)
{
	if(Cvars.x == 0)
		return CallNextHookEx(oshi.pGui-&gt;KeyHookHandle, code, wParam, lParam);

	if(oshi.pGui-&gt;CheckKey(code, wParam, lParam))
		return TRUE;

	return CallNextHookEx(oshi.pGui-&gt;KeyHookHandle, code, wParam, lParam);
}
//---------------------------------------------------------------------------
bool Gui::CheckKey(int code, WPARAM wParam, LPARAM lParam)
{
	if(!oshi.pGui-&gt;guian)
		return false;
	//Sleep(200);
	switch (wParam)
	{
		case VK_RETURN:
		{
			if(oshi.pGui-&gt;CommandLine.empty())
				return true;
			text.push_back(oshi.pGui-&gt;CommandLine);
			oshi.pGui-&gt;CommandLine.clear();
			return true;
		}
		case VK_SPACE:
		{
			oshi.pGui-&gt;CommandLine += ' ';
			return true;
		}
		case VK_BACK:
		{
			if(oshi.pGui-&gt;CommandLine.length() &gt; 0)
				oshi.pGui-&gt;CommandLine.erase(oshi.pGui-&gt;CommandLine.length() - 1, oshi.pGui-&gt;CommandLine.length());			
			return true;
		}
		default:
		{	
			if(wParam &gt; 0x40 &amp;&amp; wParam &lt; 0x5B)
			{
				if(GetAsyncKeyState(VK_SHIFT))
					oshi.pGui-&gt;CommandLine += grossbuchstaben[wParam - 0x41];
				else
					oshi.pGui-&gt;CommandLine += kleinbuchstaben[wParam - 0x41];
				return true;
			}
			else if(wParam &gt;= 0x30 &amp;&amp; wParam &lt;= 39)
			{
				if(GetAsyncKeyState(VK_SHIFT))
					return false;
				else
					oshi.pGui-&gt;CommandLine += zahlen[wParam - 0x30];
				return true;
			}
			else
			{
				char szKeyname[10];
				if(GetKeyNameText(lParam, szKeyname, 10))
				{
					if(strlen(szKeyname) == 1)
					{
						oshi.pGui-&gt;CommandLine += szKeyname;
					}
					return true;
				}
			}
		}
	}
	return false;
}
//---------------------------------------------------------------------------
</code></pre>
<p>greetz KN4CK3R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1485387</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1485387</guid><dc:creator><![CDATA[KN4CK3R]]></dc:creator><pubDate>Wed, 02 Apr 2008 17:12:25 GMT</pubDate></item><item><title><![CDATA[Reply to TastaturHook zu schnell (?) on Wed, 02 Apr 2008 17:26:46 GMT]]></title><description><![CDATA[<p>KN4CK3R schrieb:</p>
<blockquote>
<p>Denn wenn ich zB 'a' <strong>antippe</strong>, dann schreibt er 'aa' in die Variable.</p>
</blockquote>
<p>Antippen --&gt; WM_KEYDOWN + WM_KEYUP ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1485397</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1485397</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 02 Apr 2008 17:26:46 GMT</pubDate></item><item><title><![CDATA[Reply to TastaturHook zu schnell (?) on Wed, 02 Apr 2008 18:19:38 GMT]]></title><description><![CDATA[<p>ok danke, dadran habe ich nicht gedacht, nur wie baue ich das am besten ein? wparam wird ja schon für die Tasten benutzt. Oder funktioniert sowas hier in der Art?</p>
<pre><code class="language-cpp">switch(wParam)
{
      case WM_KEYDOWN:
                switch(wParam)
                {
                //mein Code
                }
		break;
}
</code></pre>
<p>Oder irre ich mich und wird WM_KEYDOWN etc nicht mit wParam ausgeliefert?</p>
<p>greetz KN4CK3R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1485439</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1485439</guid><dc:creator><![CDATA[KN4CK3R]]></dc:creator><pubDate>Wed, 02 Apr 2008 18:19:38 GMT</pubDate></item><item><title><![CDATA[Reply to TastaturHook zu schnell (?) on Wed, 02 Apr 2008 18:34:49 GMT]]></title><description><![CDATA[<p>Wenn dich eh nur einzelne Tasten interessieren, reicht es, nur WM_KEYUP abzufangen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1485459</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1485459</guid><dc:creator><![CDATA[WebFritzi]]></dc:creator><pubDate>Wed, 02 Apr 2008 18:34:49 GMT</pubDate></item><item><title><![CDATA[Reply to TastaturHook zu schnell (?) on Wed, 02 Apr 2008 18:44:59 GMT]]></title><description><![CDATA[<p>ok, habs jetzt damit gemacht:</p>
<pre><code class="language-cpp">if(lParam &amp;0x40000000 || lParam &amp;0x80000000)
</code></pre>
<p>Edit: wo wir grad dabei sind, wie ist der VK Code für . und -?</p>
<p>greetz KN4CK3R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1485465</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1485465</guid><dc:creator><![CDATA[KN4CK3R]]></dc:creator><pubDate>Wed, 02 Apr 2008 18:44:59 GMT</pubDate></item><item><title><![CDATA[Reply to TastaturHook zu schnell (?) on Wed, 02 Apr 2008 19:25:12 GMT]]></title><description><![CDATA[<p><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/VirtualKeyCodes.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/VirtualKeyCodes.asp</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1485496</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1485496</guid><dc:creator><![CDATA[dust]]></dc:creator><pubDate>Wed, 02 Apr 2008 19:25:12 GMT</pubDate></item></channel></rss>