<?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[Tastatur Hook einrichten]]></title><description><![CDATA[<p>Hallo ich habe folgende DLL erstellt</p>
<pre><code>#include &quot;dll.h&quot;

#pragma data_seg (&quot;shared&quot;)
HHOOK g_hTastaturHook  = NULL;   //Handle Hook als SHARED
#pragma data_seg ()
#pragma comment(linker,&quot;/SECTION:shared,RWS&quot;)

#pragma data_seg (&quot;shared&quot;)
HINSTANCE g_hInst = NULL;    //Handle dll
#pragma data_seg ()
#pragma comment(linker,&quot;/SECTION:shared,RWS&quot;)

BOOL APIENTRY DllMain (HINSTANCE hInst     /* Library instance handle. */ ,
                       DWORD reason        /* Reason this function is being called. */ ,
                       LPVOID reserved     /* Not used. */ )
{
    g_hInst = hInst;
    return TRUE;
}

DLLIMPORT BOOL InstallHook()

{ 
    if(g_hMouseHook != NULL)
		return TRUE;

	g_hTastaturHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, g_hInst, 0);
	if(g_hTastaturHook == NULL)
	    return FALSE;

    return TRUE;
}

DLLIMPORT BOOL UninstallHook()
{
	if(g_hTastaturHook != NULL)
	{
		UnhookWindowsHookEx(g_hTastaturHook);
		g_hMouseHook = NULL;
	}
	return TRUE;
}

LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
	if (nCode &lt; 0)
		return CallNextHookEx(g_hTastaturHook, nCode, wParam, lParam);

	if(nCode == VK_TAB) // wenn tab gedrückt
	{

	            HWND caller = FindWindow(&quot;Anwendung&quot;, NULL); 
	            if(caller != NULL)
	                PostMessage(caller, 8888, 0,0);

	}
	return CallNextHookEx(g_hTastaturHook, nCode, wParam, lParam);
}
</code></pre>
<p>Leider kommt der Hook beim drücken des Tabulators nicht an. Ist mit der</p>
<pre><code>ePostMessage(caller, 8888, 0,0);
</code></pre>
<p>etwas falsch ? ich habe auch probleme die Dll zu debuggen aber rein syntaktisch müste es doch stimmen, wenn ich in meiner Anwendung die Nachricht mit der Callback Methode abfange oder ???</p>
<pre><code>LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;
        HWND caller ;
		switch (message) 
	{
	case WM_COMMAND:
		wmId    = LOWORD(wParam); 
		wmEvent = HIWORD(wParam); 

		if(message==8888)
			MessageBox(NULL,&quot;Tabulator gedrueckt&quot;,&quot;Fehler&quot;,MB_OK);
....
</code></pre>
<p>wer kann mir helfen ?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/158201/tastatur-hook-einrichten</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Jul 2026 04:37:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/158201.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 02 Sep 2006 16:53:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Tastatur Hook einrichten on Sat, 02 Sep 2006 16:53:09 GMT]]></title><description><![CDATA[<p>Hallo ich habe folgende DLL erstellt</p>
<pre><code>#include &quot;dll.h&quot;

#pragma data_seg (&quot;shared&quot;)
HHOOK g_hTastaturHook  = NULL;   //Handle Hook als SHARED
#pragma data_seg ()
#pragma comment(linker,&quot;/SECTION:shared,RWS&quot;)

#pragma data_seg (&quot;shared&quot;)
HINSTANCE g_hInst = NULL;    //Handle dll
#pragma data_seg ()
#pragma comment(linker,&quot;/SECTION:shared,RWS&quot;)

BOOL APIENTRY DllMain (HINSTANCE hInst     /* Library instance handle. */ ,
                       DWORD reason        /* Reason this function is being called. */ ,
                       LPVOID reserved     /* Not used. */ )
{
    g_hInst = hInst;
    return TRUE;
}

DLLIMPORT BOOL InstallHook()

{ 
    if(g_hMouseHook != NULL)
		return TRUE;

	g_hTastaturHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, g_hInst, 0);
	if(g_hTastaturHook == NULL)
	    return FALSE;

    return TRUE;
}

DLLIMPORT BOOL UninstallHook()
{
	if(g_hTastaturHook != NULL)
	{
		UnhookWindowsHookEx(g_hTastaturHook);
		g_hMouseHook = NULL;
	}
	return TRUE;
}

LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
	if (nCode &lt; 0)
		return CallNextHookEx(g_hTastaturHook, nCode, wParam, lParam);

	if(nCode == VK_TAB) // wenn tab gedrückt
	{

	            HWND caller = FindWindow(&quot;Anwendung&quot;, NULL); 
	            if(caller != NULL)
	                PostMessage(caller, 8888, 0,0);

	}
	return CallNextHookEx(g_hTastaturHook, nCode, wParam, lParam);
}
</code></pre>
<p>Leider kommt der Hook beim drücken des Tabulators nicht an. Ist mit der</p>
<pre><code>ePostMessage(caller, 8888, 0,0);
</code></pre>
<p>etwas falsch ? ich habe auch probleme die Dll zu debuggen aber rein syntaktisch müste es doch stimmen, wenn ich in meiner Anwendung die Nachricht mit der Callback Methode abfange oder ???</p>
<pre><code>LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;
        HWND caller ;
		switch (message) 
	{
	case WM_COMMAND:
		wmId    = LOWORD(wParam); 
		wmEvent = HIWORD(wParam); 

		if(message==8888)
			MessageBox(NULL,&quot;Tabulator gedrueckt&quot;,&quot;Fehler&quot;,MB_OK);
....
</code></pre>
<p>wer kann mir helfen ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1129769</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1129769</guid><dc:creator><![CDATA[abacs]]></dc:creator><pubDate>Sat, 02 Sep 2006 16:53:09 GMT</pubDate></item><item><title><![CDATA[Reply to Tastatur Hook einrichten on Sat, 02 Sep 2006 17:52:36 GMT]]></title><description><![CDATA[<p>Da fehlt ein 'break;' vor:</p>
<pre><code class="language-cpp">if(message==8888)
            MessageBox(NULL,&quot;Tabulator gedrueckt&quot;,&quot;Fehler&quot;,MB_OK);
</code></pre>
<p>So würde er nur bei if(message==888... ankommen, wenn message = WM_COMMAND wäre...irg-wie Schwachsinn oder <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1129813</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1129813</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sat, 02 Sep 2006 17:52:36 GMT</pubDate></item><item><title><![CDATA[Reply to Tastatur Hook einrichten on Sat, 02 Sep 2006 18:03:31 GMT]]></title><description><![CDATA[<p>Immer diese Profis, die mein Password ausspionieren wollen nd dann solche Fehler machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1129825</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1129825</guid><dc:creator><![CDATA[Och...]]></dc:creator><pubDate>Sat, 02 Sep 2006 18:03:31 GMT</pubDate></item><item><title><![CDATA[Reply to Tastatur Hook einrichten on Sat, 02 Sep 2006 23:07:49 GMT]]></title><description><![CDATA[<p>Och... schrieb:</p>
<blockquote>
<p>Immer diese Profis, die mein Password ausspionieren wollen nd dann solche Fehler machen.</p>
</blockquote>
<p>Man kann Hooks ja auch für andere Dinge verwenden...@OP: Hoffe mal das tuts du auch <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1129939</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1129939</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sat, 02 Sep 2006 23:07:49 GMT</pubDate></item></channel></rss>