<?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[KeyboardHook]]></title><description><![CDATA[<p>Könnte mir mal einer sagen, wieso dieser Hook nicht funktioniert?</p>
<pre><code class="language-cpp">#include &lt;stdio.h&gt;
#include &lt;iostream&gt;
#include &lt;windows.h&gt;

using namespace std;

LRESULT CALLBACK KeyboardProc(int code, WPARAM wParam, LPARAM lParam)
{
	if(code == HC_ACTION)
	{
		//MessageBeep(0xFFFFFFFF);
		MessageBox(NULL, &quot;Hook aktiv\nDu hast eine Taste gedrückt&quot;, &quot;Keyboard Hook Event&quot;,MB_OK);
	}
	return 0;
}

int main()
{
	HHOOK Hook_ID = NULL;
	if(Hook_ID == NULL)
	{
		Hook_ID = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) KeyboardProc, 0, GetCurrentThreadId());
		if(Hook_ID != NULL)
			MessageBox(NULL,&quot;Hook wurde gesetzt&quot;,&quot;Keyboard Hook Event&quot;,MB_OK);
		else
			MessageBox(NULL,&quot;Hook wurde nicht gesetzt&quot;,&quot;Keyboard Hook Event&quot;,MB_OK);
	}

	int x;
	std::cin&gt;&gt;x;
}
</code></pre>
<p>Compiliert wurde mit VS2008 im 64Bit Mode unter Vista 64Bit.<br />
Bekomme auch die Meldung zurück, dass der Hook registriert wurde aber er wird einfach nicht angesprungen. In diesem Fall ist mir erstmal völlig egal was für eine Taste gedrückt wird. Es soll einfach nur eine Message Box aufgehen wenn überhaupt eine Taste gedrückt wird. Eigentlich ist der Code fast 1:1 aus einem Buch abkopiert und trotzdem will das nicht so recht</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/239908/keyboardhook</link><generator>RSS for Node</generator><lastBuildDate>Mon, 06 Apr 2026 11:39:45 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/239908.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 29 Apr 2009 12:47:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to KeyboardHook on Wed, 29 Apr 2009 12:47:42 GMT]]></title><description><![CDATA[<p>Könnte mir mal einer sagen, wieso dieser Hook nicht funktioniert?</p>
<pre><code class="language-cpp">#include &lt;stdio.h&gt;
#include &lt;iostream&gt;
#include &lt;windows.h&gt;

using namespace std;

LRESULT CALLBACK KeyboardProc(int code, WPARAM wParam, LPARAM lParam)
{
	if(code == HC_ACTION)
	{
		//MessageBeep(0xFFFFFFFF);
		MessageBox(NULL, &quot;Hook aktiv\nDu hast eine Taste gedrückt&quot;, &quot;Keyboard Hook Event&quot;,MB_OK);
	}
	return 0;
}

int main()
{
	HHOOK Hook_ID = NULL;
	if(Hook_ID == NULL)
	{
		Hook_ID = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) KeyboardProc, 0, GetCurrentThreadId());
		if(Hook_ID != NULL)
			MessageBox(NULL,&quot;Hook wurde gesetzt&quot;,&quot;Keyboard Hook Event&quot;,MB_OK);
		else
			MessageBox(NULL,&quot;Hook wurde nicht gesetzt&quot;,&quot;Keyboard Hook Event&quot;,MB_OK);
	}

	int x;
	std::cin&gt;&gt;x;
}
</code></pre>
<p>Compiliert wurde mit VS2008 im 64Bit Mode unter Vista 64Bit.<br />
Bekomme auch die Meldung zurück, dass der Hook registriert wurde aber er wird einfach nicht angesprungen. In diesem Fall ist mir erstmal völlig egal was für eine Taste gedrückt wird. Es soll einfach nur eine Message Box aufgehen wenn überhaupt eine Taste gedrückt wird. Eigentlich ist der Code fast 1:1 aus einem Buch abkopiert und trotzdem will das nicht so recht</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1703138</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1703138</guid><dc:creator><![CDATA[secondsun]]></dc:creator><pubDate>Wed, 29 Apr 2009 12:47:42 GMT</pubDate></item><item><title><![CDATA[Reply to KeyboardHook on Wed, 29 Apr 2009 14:53:59 GMT]]></title><description><![CDATA[<p>Hab noch nie mit Einstellung 64-Bit compiliert, daher nur ein Tipp:</p>
<p>LRESULT CALLBACK KeyboardProc( <strong>int code</strong>, WPARAM wParam, LPARAM lParam)</p>
<p>Kann es sein daß bei 64-Bit Einstellung der int als 64-Bit Wert definiert ist und deshalb mit dem Wert HC_ACTION (welcher wahrscheinlich 32-Bit ist) nicht übereinstimmt?</p>
<p>Daher:<br />
1. Compiliere mit 32-Bit Einstellung -&gt; Ergebnis?<br />
2. Den Typ int oder den Wert HC_ACTION casten.<br />
3. Evtl. die oberen 32 Bits von int ausmaskieren.</p>
<p>Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1703211</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1703211</guid><dc:creator><![CDATA[Mmacher]]></dc:creator><pubDate>Wed, 29 Apr 2009 14:53:59 GMT</pubDate></item></channel></rss>