<?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[Virtueller Zähler für GetAsyncKeyState oder doch einfacher?]]></title><description><![CDATA[<p>hi,</p>
<p>Ich hab ne Schleife die so aussieht:</p>
<pre><code class="language-cpp">for(;;) {
if(GetAsyncKeyState(VK_NUMPAD1) {
     doAnything();
}

Sleep(100);

}
</code></pre>
<p>Mein Problem ist jetzt, dass wen ich einaml Numpad1 drücke doAnything gleich 3-5 mal ausgeführt wird.<br />
Meine Idee ist es jetzt nen couter zu bauen der ab 1++ die schleife ignoriert und den counter nach 2min resettet aber das ist unnormal kompliziert.<br />
Hat jemand eine andere lösung?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/145112/virtueller-zähler-für-getasynckeystate-oder-doch-einfacher</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Jul 2026 21:17:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/145112.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 25 Apr 2006 04:11:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Virtueller Zähler für GetAsyncKeyState oder doch einfacher? on Tue, 25 Apr 2006 04:11:52 GMT]]></title><description><![CDATA[<p>hi,</p>
<p>Ich hab ne Schleife die so aussieht:</p>
<pre><code class="language-cpp">for(;;) {
if(GetAsyncKeyState(VK_NUMPAD1) {
     doAnything();
}

Sleep(100);

}
</code></pre>
<p>Mein Problem ist jetzt, dass wen ich einaml Numpad1 drücke doAnything gleich 3-5 mal ausgeführt wird.<br />
Meine Idee ist es jetzt nen couter zu bauen der ab 1++ die schleife ignoriert und den counter nach 2min resettet aber das ist unnormal kompliziert.<br />
Hat jemand eine andere lösung?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1044549</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1044549</guid><dc:creator><![CDATA[kirlo]]></dc:creator><pubDate>Tue, 25 Apr 2006 04:11:52 GMT</pubDate></item><item><title><![CDATA[Reply to Virtueller Zähler für GetAsyncKeyState oder doch einfacher? on Tue, 25 Apr 2006 07:24:17 GMT]]></title><description><![CDATA[<p>Du solltest mal grob sagen, was Du eigentlich tun willst...<br />
Wenn die &quot;doAnything&quot; nur einmal aufgerufen werden sollte, dann musst Du dir merken, dass Du sie aufgerufen hast und dann warten, bis die Taste wieder losgelassen wurde und dann den merker zurücksetzen...</p>
<p>Ganz abgesehen davon, bekommst Du hier kurze Tastendrücke nicht mit...<br />
I.d.R. macht man sowas mit Keyboard-Hooks...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1044599</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1044599</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Tue, 25 Apr 2006 07:24:17 GMT</pubDate></item><item><title><![CDATA[Reply to Virtueller Zähler für GetAsyncKeyState oder doch einfacher? on Tue, 25 Apr 2006 07:49:56 GMT]]></title><description><![CDATA[<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. However, you should not rely on this last behavior; for more information, see the Remarks.<br />
[...]<br />
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>
]]></description><link>https://www.c-plusplus.net/forum/post/1044605</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1044605</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Tue, 25 Apr 2006 07:49:56 GMT</pubDate></item><item><title><![CDATA[Reply to Virtueller Zähler für GetAsyncKeyState oder doch einfacher? on Tue, 25 Apr 2006 08:26:55 GMT]]></title><description><![CDATA[<p>hmm hat wer dazu viell. ein Beispiel?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1044633</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1044633</guid><dc:creator><![CDATA[fwef]]></dc:creator><pubDate>Tue, 25 Apr 2006 08:26:55 GMT</pubDate></item><item><title><![CDATA[Reply to Virtueller Zähler für GetAsyncKeyState oder doch einfacher? on Tue, 25 Apr 2006 08:32:43 GMT]]></title><description><![CDATA[<p>Also ok, ich werde ein Keyboard hook bauen wie hier:<br />
<a href="http://www.codeproject.com/dll/keyboardhook.asp" rel="nofollow">http://www.codeproject.com/dll/keyboardhook.asp</a></p>
<p>(ich weiss auch schon ein kleines beispiel das mir hilft)</p>
<p>achja zu for(;;) {<br />
if(GetAsyncKeyState(VK_NUMPAD1) == 1) { cout&lt;&lt;&quot;bla&quot;; }<br />
}</p>
<p>Das hat nich funktioniert wegen &quot;==1&quot; also if(GetAsyncKeyState(VK_NUMPAD1)) { cout&lt;&lt;&quot;bla&quot;; }</p>
<p>Was ein verherrender fehler ;/</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1044637</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1044637</guid><dc:creator><![CDATA[fewf]]></dc:creator><pubDate>Tue, 25 Apr 2006 08:32:43 GMT</pubDate></item><item><title><![CDATA[Reply to Virtueller Zähler für GetAsyncKeyState oder doch einfacher? on Tue, 25 Apr 2006 08:44:13 GMT]]></title><description><![CDATA[<p>Wenn du einzelne Bits abfragen willst, mußt du den Rückgabewert per &amp;|^ zerlegen:</p>
<pre><code class="language-cpp">if((getAsyncKeyState(VK_NUMPAD1)&amp;1)!=0)...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1044644</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1044644</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 25 Apr 2006 08:44:13 GMT</pubDate></item><item><title><![CDATA[Reply to Virtueller Zähler für GetAsyncKeyState oder doch einfacher? on Tue, 25 Apr 2006 10:33:26 GMT]]></title><description><![CDATA[<p>Ok das funktioniert schon recht gut aber wenn ich nen keyboard hook baue der so funktioniert;</p>
<p>LRESULT CALLBACK HookedWindowProcedure(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)<br />
{<br />
switch(message)<br />
{<br />
case WM_DOWN:<br />
{<br />
wParam==VK_LEFT<br />
}<br />
break;<br />
}</p>
<p>}</p>
<p>kann ich dann die taste gedürckt halten oder ist das dann genauso wie numpad1&amp;1?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1044725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1044725</guid><dc:creator><![CDATA[dwef]]></dc:creator><pubDate>Tue, 25 Apr 2006 10:33:26 GMT</pubDate></item></channel></rss>