<?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[Abbruch einer Schleife]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich habe ein kleines Problem.<br />
Ich habe mich an die Arbeit gemacht und wollte ein kleines Programm zum Autoklicken erstellen.<br />
Das ganze sollte so aussehen, dass wenn ich die linke Maustaste gedrückt halte, mein Rechner in dieser Zeit mit hoher Frequenz klickt.<br />
Das funktioniert in sofern leider nicht, dass mein Programm, einmal gestartet, nicht aufhört zu klicken. Deshalb habe ich mich informiert und ein &quot;break&quot; eingebaut, dieser bricht aber leider nur die innere schleife für kurze zeit und nicht die äußere. Hier ist der code, den ich bis jetzt geschrieben, bzw copiert habe...</p>
<blockquote>
<p>#include &lt;windows.h&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;conio.h&gt;</p>
<p>using namespace std;</p>
<p>using namespace std;</p>
<p>int main(int argc, char* argv[])<br />
{<br />
INPUT_RECORD inRec;</p>
<p>HANDLE hcon = GetStdHandle(STD_INPUT_HANDLE);</p>
<p>while(1)<br />
{ cout &lt;&lt; &quot;While 1&quot; &lt;&lt; endl;<br />
DWORD nCnt = 0;<br />
BOOL bOK = ReadConsoleInput(hcon, &amp;inRec, 1, &amp;nCnt);<br />
if(GetAsyncKeyState(VK_CONTROL))<br />
{<br />
if(bOK &amp;&amp; nCnt == 1)<br />
{<br />
if(inRec.EventType == MOUSE_EVENT)<br />
{<br />
while(inRec.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED)<br />
{ cout &lt;&lt; &quot;While 2&quot; &lt;&lt; endl;<br />
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);<br />
Sleep(20);<br />
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);<br />
Sleep(20);<br />
if (GetAsyncKeyState(VK_CONTROL))<br />
{<br />
break;<br />
}<br />
else continue;<br />
}<br />
}<br />
}<br />
}<br />
}<br />
return 0;<br />
}</p>
</blockquote>
<p>ps: ich bin ein absoluter Noob im Umgang mit C++... Mit Java bin ich auch nur am Anfang...</p>
<p>MFG</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/227836/abbruch-einer-schleife</link><generator>RSS for Node</generator><lastBuildDate>Tue, 29 Sep 2026 19:25:39 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/227836.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Nov 2008 14:41:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Abbruch einer Schleife on Thu, 20 Nov 2008 14:41:41 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich habe ein kleines Problem.<br />
Ich habe mich an die Arbeit gemacht und wollte ein kleines Programm zum Autoklicken erstellen.<br />
Das ganze sollte so aussehen, dass wenn ich die linke Maustaste gedrückt halte, mein Rechner in dieser Zeit mit hoher Frequenz klickt.<br />
Das funktioniert in sofern leider nicht, dass mein Programm, einmal gestartet, nicht aufhört zu klicken. Deshalb habe ich mich informiert und ein &quot;break&quot; eingebaut, dieser bricht aber leider nur die innere schleife für kurze zeit und nicht die äußere. Hier ist der code, den ich bis jetzt geschrieben, bzw copiert habe...</p>
<blockquote>
<p>#include &lt;windows.h&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;conio.h&gt;</p>
<p>using namespace std;</p>
<p>using namespace std;</p>
<p>int main(int argc, char* argv[])<br />
{<br />
INPUT_RECORD inRec;</p>
<p>HANDLE hcon = GetStdHandle(STD_INPUT_HANDLE);</p>
<p>while(1)<br />
{ cout &lt;&lt; &quot;While 1&quot; &lt;&lt; endl;<br />
DWORD nCnt = 0;<br />
BOOL bOK = ReadConsoleInput(hcon, &amp;inRec, 1, &amp;nCnt);<br />
if(GetAsyncKeyState(VK_CONTROL))<br />
{<br />
if(bOK &amp;&amp; nCnt == 1)<br />
{<br />
if(inRec.EventType == MOUSE_EVENT)<br />
{<br />
while(inRec.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED)<br />
{ cout &lt;&lt; &quot;While 2&quot; &lt;&lt; endl;<br />
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);<br />
Sleep(20);<br />
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);<br />
Sleep(20);<br />
if (GetAsyncKeyState(VK_CONTROL))<br />
{<br />
break;<br />
}<br />
else continue;<br />
}<br />
}<br />
}<br />
}<br />
}<br />
return 0;<br />
}</p>
</blockquote>
<p>ps: ich bin ein absoluter Noob im Umgang mit C++... Mit Java bin ich auch nur am Anfang...</p>
<p>MFG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1617766</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1617766</guid><dc:creator><![CDATA[mindfreak]]></dc:creator><pubDate>Thu, 20 Nov 2008 14:41:41 GMT</pubDate></item><item><title><![CDATA[Reply to Abbruch einer Schleife on Thu, 20 Nov 2008 14:43:54 GMT]]></title><description><![CDATA[<p>Für einfach noch eine boolsche Variable ein, zb bool keepRunning = true; und frag darauf zusätzlich in den Schleifen ab und setz sie vor/statt deinem break. <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/1617767</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1617767</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Thu, 20 Nov 2008 14:43:54 GMT</pubDate></item><item><title><![CDATA[Reply to Abbruch einer Schleife on Thu, 20 Nov 2008 14:48:06 GMT]]></title><description><![CDATA[<p>ok danke sehr!<br />
werde ich gleich mal ausprobieren!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1617770</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1617770</guid><dc:creator><![CDATA[mindfreak]]></dc:creator><pubDate>Thu, 20 Nov 2008 14:48:06 GMT</pubDate></item><item><title><![CDATA[Reply to Abbruch einer Schleife on Thu, 20 Nov 2008 15:02:49 GMT]]></title><description><![CDATA[<p>leider hats nicht wirklich geholfen.<br />
er setzt die variable zwar auf true wenn ich controle drücke, geht aber nicht in die 2. schleife...<br />
mein code mit bool:</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;iostream&gt;
#include &lt;conio.h&gt;

using namespace std;

using namespace std;

int main(int argc, char* argv[])
{
  INPUT_RECORD inRec;
  bool run=false;
  HANDLE hcon = GetStdHandle(STD_INPUT_HANDLE);
  while(1)
  {          cout &lt;&lt; &quot;While 1&quot; &lt;&lt; endl;
   DWORD nCnt = 0;
   BOOL bOK = ReadConsoleInput(hcon, &amp;inRec, 1, &amp;nCnt);
   if(GetAsyncKeyState(VK_CONTROL))
   {
      bool run=true;
      cout &lt;&lt; &quot;true&quot; &lt;&lt; endl;
      Sleep(1000)
   }
   if(bOK &amp;&amp; nCnt == 1)
    {
    if(inRec.EventType == MOUSE_EVENT)
     {
     while(inRec.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED&amp;&amp; run==true)
      {          cout &lt;&lt; &quot;While 2&quot; &lt;&lt; endl;
      mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
      Sleep(20);
      mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
      Sleep(20);
      if (GetAsyncKeyState(VK_CONTROL))
        {
		bool run=false;
		}
		else continue;
      }
      }
    }
  }
 return 0;
 }
</code></pre>
<p>die couts sind nur dafür da, damit ich weiss in welche schleife er ist...</p>
<p>MFG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1617782</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1617782</guid><dc:creator><![CDATA[mindfreak]]></dc:creator><pubDate>Thu, 20 Nov 2008 15:02:49 GMT</pubDate></item><item><title><![CDATA[Reply to Abbruch einer Schleife on Thu, 20 Nov 2008 15:04:15 GMT]]></title><description><![CDATA[<p>Pack hinter die zweite Schleife ein if (run == false) break; und fertig.<br />
Ist zwar keine schöne Methode aber (sorry) das macht da auch keinen Unterschied. <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/1617783</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1617783</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Thu, 20 Nov 2008 15:04:15 GMT</pubDate></item><item><title><![CDATA[Reply to Abbruch einer Schleife on Thu, 20 Nov 2008 15:06:38 GMT]]></title><description><![CDATA[<p>mindfreak schrieb:</p>
<blockquote>
<p>leider hats nicht wirklich geholfen.<br />
er setzt die variable zwar auf true wenn ich controle drücke, geht aber nicht in die 2. schleife...</p>
</blockquote>
<p>Was erwartest du, wenn du nicht die eigentliche Variable änderst, sondern jedesmal eine neue lokale Variable deklarierst.</p>
<pre><code class="language-cpp">int main()
{
    bool run = false; // Variablendeklaration mit initialisierung
    {
        bool run = true; // Variablendeklaration mit initialisierung
        // dies ist eine NEUE Variable
    }
    run = true; // So sieht eine Zuweisung aus
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1617786</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1617786</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Thu, 20 Nov 2008 15:06:38 GMT</pubDate></item><item><title><![CDATA[Reply to Abbruch einer Schleife on Thu, 20 Nov 2008 15:17:27 GMT]]></title><description><![CDATA[<p>er geht ja garnicht erst in die 2. schleife rein und ich glaub das hat was mit dem bool zutun falls ich nämlich in einer fallunterscheidung &amp;&amp;run==true reinpacke, wird diese nicht mehr ausgeführt...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1617791</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1617791</guid><dc:creator><![CDATA[mindfreak]]></dc:creator><pubDate>Thu, 20 Nov 2008 15:17:27 GMT</pubDate></item><item><title><![CDATA[Reply to Abbruch einer Schleife on Thu, 20 Nov 2008 15:18:33 GMT]]></title><description><![CDATA[<p>sorry.. wie gesagt ich bin absoluter anfänger auf dem c++ gebiet... hab nur ein bisschen rumprobiert... aber danke ich werds ändern</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1617792</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1617792</guid><dc:creator><![CDATA[mindfreak]]></dc:creator><pubDate>Thu, 20 Nov 2008 15:18:33 GMT</pubDate></item><item><title><![CDATA[Reply to Abbruch einer Schleife on Thu, 20 Nov 2008 15:20:15 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;iostream&gt;
#include &lt;conio.h&gt;

using namespace std;

using namespace std;

int main(int argc, char* argv[])
{
  INPUT_RECORD inRec;

  HANDLE hcon = GetStdHandle(STD_INPUT_HANDLE);

  bool run = true;

  while(run)
  {
   cout &lt;&lt; &quot;While 1&quot; &lt;&lt; endl;
   DWORD nCnt = 0;
   BOOL bOK = ReadConsoleInput(hcon, &amp;inRec, 1, &amp;nCnt);
   if(GetAsyncKeyState(VK_CONTROL))
   {
     if(bOK &amp;&amp; nCnt == 1)
     {
       if(inRec.EventType == MOUSE_EVENT)
       {
         while(inRec.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED)
         {  
           cout &lt;&lt; &quot;While 2&quot; &lt;&lt; endl;
           mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
           Sleep(20);
           mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
           Sleep(20);
           if (GetAsyncKeyState(VK_CONTROL))
           {
             run = false;
	     break;
           }
         }
      }
    }
  }
}
 return 0;
 }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1617793</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1617793</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Thu, 20 Nov 2008 15:20:15 GMT</pubDate></item><item><title><![CDATA[Reply to Abbruch einer Schleife on Thu, 20 Nov 2008 15:42:59 GMT]]></title><description><![CDATA[<p>Vielen dank für die hilfe, aber das programm läuft nun nur einmal durch und das wars... naja.. ich danke ihnen vielmals...<br />
falls jemand von ihnen einen solchen autoklicker schonmal in c++ geschrieben hat kann derjenige sich vllt bei mir melden denn mit meinen ahk scripten is die ganze sache ziemlich langsam...<br />
hier ein beispiel von ahk:</p>
<pre><code>autoklick() 
   { 

	loop	
	{	

   		Click down left
   		Sleep 25
   		Click up left 
   		Sleep 25
		GetKeyState, LButtonState, LButton, P
		IF LButtonState = U
		{
		break
		}		   

	}

   }
</code></pre>
<p>mit vielen freundlichen grüßen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1617808</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1617808</guid><dc:creator><![CDATA[mindfreak]]></dc:creator><pubDate>Thu, 20 Nov 2008 15:42:59 GMT</pubDate></item></channel></rss>