<?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[Low-Level Keyboard Hook]]></title><description><![CDATA[<p>Hallo,<br />
ich habe Probleme mit meinen LowLevel Keyboard Hook:</p>
<pre><code class="language-cpp">SetWindowsHookEx(WH_KEYBOARD_LL,(HOOKPROC)LowLevelKeybdProc,hDllInstance,0);

LRESULT CALLBACK LowLevelKeybdProc(int nCode,WPARAM wParam, LPARAM lParam)
{
    if (nCode == HC_ACTION)
    {
	switch(wParam)
	{
            case WM_KEYDOWN:
		DebugTrace(&quot;LowLevelKeyb...WM_KEYDOWN&quot;);
		break;
	    case WM_KEYUP:
		DebugTrace(&quot;LowLevelKeyb...WM_KEYUP&quot;);
		break;
	    case WM_SYSKEYDOWN:
		DebugTrace(&quot;LowLevelKeyb...WM_SYSKEYDOWN&quot;);
		break;
	    case WM_SYSKEYUP:
		DebugTrace(&quot;LowLevelKeyb...WM_SYSKEYUP&quot;);
		break;
	}
        ....
    }
    return CallNextHookEx (NULL, nCode, wParam, lParam) ;
}
</code></pre>
<p>Lässt sich zwar fehlerfrei ausführen,<br />
aber ich bekomme wenn ich eine Taste 'normal' drücke nur<br />
einen WM_KEYUP!!<br />
Drücke eine Taste länger bekomme ich mehrere WM_KEYDOWN's<br />
aber auch erst nach den WM_KEYUP's!!</p>
<p>Woran könnte das liegen?? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Wäre für jede Hilfe dankbar.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/65895/low-level-keyboard-hook</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Apr 2026 00:09:17 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/65895.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 23 Feb 2004 14:02:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Low-Level Keyboard Hook on Mon, 23 Feb 2004 14:02:26 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich habe Probleme mit meinen LowLevel Keyboard Hook:</p>
<pre><code class="language-cpp">SetWindowsHookEx(WH_KEYBOARD_LL,(HOOKPROC)LowLevelKeybdProc,hDllInstance,0);

LRESULT CALLBACK LowLevelKeybdProc(int nCode,WPARAM wParam, LPARAM lParam)
{
    if (nCode == HC_ACTION)
    {
	switch(wParam)
	{
            case WM_KEYDOWN:
		DebugTrace(&quot;LowLevelKeyb...WM_KEYDOWN&quot;);
		break;
	    case WM_KEYUP:
		DebugTrace(&quot;LowLevelKeyb...WM_KEYUP&quot;);
		break;
	    case WM_SYSKEYDOWN:
		DebugTrace(&quot;LowLevelKeyb...WM_SYSKEYDOWN&quot;);
		break;
	    case WM_SYSKEYUP:
		DebugTrace(&quot;LowLevelKeyb...WM_SYSKEYUP&quot;);
		break;
	}
        ....
    }
    return CallNextHookEx (NULL, nCode, wParam, lParam) ;
}
</code></pre>
<p>Lässt sich zwar fehlerfrei ausführen,<br />
aber ich bekomme wenn ich eine Taste 'normal' drücke nur<br />
einen WM_KEYUP!!<br />
Drücke eine Taste länger bekomme ich mehrere WM_KEYDOWN's<br />
aber auch erst nach den WM_KEYUP's!!</p>
<p>Woran könnte das liegen?? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Wäre für jede Hilfe dankbar.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/465926</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/465926</guid><dc:creator><![CDATA[alex25]]></dc:creator><pubDate>Mon, 23 Feb 2004 14:02:26 GMT</pubDate></item><item><title><![CDATA[Reply to Low-Level Keyboard Hook on Mon, 23 Feb 2004 14:16:24 GMT]]></title><description><![CDATA[<p>Hmm. Es ist prinzipiell völlig unmöglich, dass WM_KEYUP vor WM_KEYDOWN kommt. Lass mich noch darüber nachdenken. Ich hab auch mal ein LowLevelKeyboard-Hook geschrieben...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/465938</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/465938</guid><dc:creator><![CDATA[Aziz]]></dc:creator><pubDate>Mon, 23 Feb 2004 14:16:24 GMT</pubDate></item><item><title><![CDATA[Reply to Low-Level Keyboard Hook on Mon, 23 Feb 2004 14:29:53 GMT]]></title><description><![CDATA[<p>Ich denke es kann nur an deinem Code liegen...Ich vermute es könnte an der folgenden Zeile liegen:</p>
<p><strong>if (nCode == HC_ACTION)</strong></p>
<p>Hier ist mein Code:</p>
<pre><code class="language-cpp">static LRESULT CALLBACK LLKeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
  //if (nCode &lt; 0)
  //  return CallNextHookEx(g_hKeyboardHook, nCode, wParam, lParam);
  static BOOL bEventSet = 0;

  PKBDLLHOOKSTRUCT pKbdStruct = reinterpret_cast&lt;PKBDLLHOOKSTRUCT&gt;(lParam);
  if(pKbdStruct-&gt;vkCode != VK_M)
    return 0; // return 0 = ok, return 1 = Input verwerfen

  switch (wParam)
  {
    case WM_KEYDOWN:
      switch(pKbdStruct-&gt;vkCode)
      {
        case VK_M:
          if(!bEventSet)
          {
            SetEvent(g_hEvent); // Signale Event, so that ThreadProc starts doing its job
            bEventSet = 1;
          }
          return 1;
          break;
      }
      break;
    case WM_KEYUP:
      switch(pKbdStruct-&gt;vkCode)
      {
        case VK_M:
          ResetEvent(g_hEvent); // Unsignale Event, so that ThreadProc stops doing its job
          bEventSet = 0;
          return 1;
          break;
      }
      break;
  }

  /**/
  LOG(&quot;Nachricht erhalten:\n&quot;);
  LOG(&quot;wParam = &quot;&lt;&lt;wParam);
  /*
  switch (wParam)
  {
    case WM_SYSKEYDOWN:
      LOG(&quot; WM_SYSKEYDOWN&quot;);
      break;
    case WM_SYSKEYUP:
      LOG(&quot; WM_SYSKEYUP&quot;);
      break;
    case WM_KEYDOWN:
      LOG(&quot; WM_KEYDOWN&quot;);
      break;
    case WM_KEYUP:
      LOG(&quot; WM_KEYUP&quot;);
      break;
  }
  */
  LOG(&quot;vkCode = &quot;&lt;&lt;pKbdStruct-&gt;vkCode&lt;&lt;endl);
  LOG(&quot;scCode = &quot;&lt;&lt;pKbdStruct-&gt;scanCode&lt;&lt;endl);
  LOG(&quot;flags  = &quot;&lt;&lt;pKbdStruct-&gt;flags&lt;&lt;( (pKbdStruct-&gt;flags &amp; 0x10)?&quot; injected&quot;:&quot;&quot; )&lt;&lt;endl);
  LOG(&quot;time   = &quot;&lt;&lt;pKbdStruct-&gt;time&lt;&lt;endl);
  LOG(&quot;dwInfo = &quot;&lt;&lt;pKbdStruct-&gt;dwExtraInfo&lt;&lt;&quot;\n\n&quot;&lt;&lt;endl);
  /**/

  return CallNextHookEx(g_hKeyboardHook, nCode, wParam, lParam); // return 0 = ok, return 1 = Input verwerfen
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/465958</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/465958</guid><dc:creator><![CDATA[Aziz]]></dc:creator><pubDate>Mon, 23 Feb 2004 14:29:53 GMT</pubDate></item><item><title><![CDATA[Reply to Low-Level Keyboard Hook on Mon, 23 Feb 2004 14:51:08 GMT]]></title><description><![CDATA[<p>Danke für die Mühe.<br />
Hab meine Funktion mal durch deine<br />
ersetzt , hat aber leider keine Besserung gebracht,<br />
habe weiterhin nur die WM_KEYUP's bekommen.</p>
<p>Gruss Alex.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/465981</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/465981</guid><dc:creator><![CDATA[alex25]]></dc:creator><pubDate>Mon, 23 Feb 2004 14:51:08 GMT</pubDate></item><item><title><![CDATA[Reply to Low-Level Keyboard Hook on Mon, 23 Feb 2004 14:56:45 GMT]]></title><description><![CDATA[<p>Hast du das jetzt direkt im Hook getestet, oder über das Hauptprogramm?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/465989</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/465989</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Mon, 23 Feb 2004 14:56:45 GMT</pubDate></item><item><title><![CDATA[Reply to Low-Level Keyboard Hook on Mon, 23 Feb 2004 15:11:09 GMT]]></title><description><![CDATA[<p>Über's Hauptprogramm, denke ich.<br />
Ich verstehe nicht ganz was du mit direkt<br />
im Hook meinst.</p>
<p>Grüsse Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/466005</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/466005</guid><dc:creator><![CDATA[alex25]]></dc:creator><pubDate>Mon, 23 Feb 2004 15:11:09 GMT</pubDate></item><item><title><![CDATA[Reply to Low-Level Keyboard Hook on Mon, 23 Feb 2004 15:24:07 GMT]]></title><description><![CDATA[<p>Du könntest ja direkt in der Hook-Proc z.B. mit einer MessageBox testen, ob vielleicht der Fehler nur in der Weiterleitung liegt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/466026</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/466026</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Mon, 23 Feb 2004 15:24:07 GMT</pubDate></item><item><title><![CDATA[Reply to Low-Level Keyboard Hook on Mon, 23 Feb 2004 15:30:12 GMT]]></title><description><![CDATA[<p>Ach so,<br />
ja die Ausgaben sind direkt in der HookProc,<br />
und hier bekomme ich eben nur die WM_KEYUP.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/466037</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/466037</guid><dc:creator><![CDATA[alex25]]></dc:creator><pubDate>Mon, 23 Feb 2004 15:30:12 GMT</pubDate></item><item><title><![CDATA[Reply to Low-Level Keyboard Hook on Mon, 23 Feb 2004 16:43:59 GMT]]></title><description><![CDATA[<p>Aziz schrieb:</p>
<blockquote>
<pre><code class="language-cpp">static LRESULT CALLBACK LLKeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
  //if (nCode &lt; 0)
  //  return CallNextHookEx(g_hKeyboardHook, nCode, wParam, lParam);
</code></pre>
</blockquote>
<p>Warum sind diese beiden Zeilen auskommentiert?</p>
<p>Die Platform-SDK Doku sagt dazu:</p>
<blockquote>
<p><strong>nCode</strong><br />
[in] Specifies a code the hook procedure uses to determine how to process the message. <strong>If nCode is less than zero, the hook procedure must pass the message to the CallNextHookEx function without further processing and should return the value returned by CallNextHookEx.</strong></p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/466105</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/466105</guid><dc:creator><![CDATA[Christoph]]></dc:creator><pubDate>Mon, 23 Feb 2004 16:43:59 GMT</pubDate></item><item><title><![CDATA[Reply to Low-Level Keyboard Hook on Tue, 24 Feb 2004 15:57:03 GMT]]></title><description><![CDATA[<p>der keyboardhook gehoert in 'ne dll und nicht in das haupprog.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/466924</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/466924</guid><dc:creator><![CDATA[ich_ich]]></dc:creator><pubDate>Tue, 24 Feb 2004 15:57:03 GMT</pubDate></item><item><title><![CDATA[Reply to Low-Level Keyboard Hook on Tue, 24 Feb 2004 16:08:26 GMT]]></title><description><![CDATA[<p>ich_ich schrieb:</p>
<blockquote>
<p>der keyboardhook gehoert in 'ne dll und nicht in das haupprog.</p>
</blockquote>
<p>Der Keyboardhook ist selbstverständlich in einer dll!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/466940</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/466940</guid><dc:creator><![CDATA[alex25]]></dc:creator><pubDate>Tue, 24 Feb 2004 16:08:26 GMT</pubDate></item></channel></rss>