How to write a Loop
<p>I am working on something and I am stumped with 2 things.   </p>

<p>The first is, I am trying to make a sort of counter that uses <code>PostMessage</code> to type from 0000 to 3600.
I need it to stop every few times it PostMessage the number and execute another part of the code, then after that code is done continue for another say 10 times then execute that same code, and so on. </p>

<p>Second: I need a function that will detect if a certain color is in a certain pixel, and if it is then it will execute some more code.</p>

<p>Here's the code that I tried, but failed with:  </p>

<pre><code>void loop()
{
    int start = Convert.ToInt32(textbox1.Text);
    for (int i = start;i == 9999; i++)
        if(i == 0004)
        PostMessage(hWnd, WM_CHAR, i, 0);
}
</code></pre>

<p>Here's the last version, which also does not work:</p>

<pre><code>void function()       
{       
    for (int i = 0000; i &lt;= 3600; i++)       
    {       
        PostMessage(hWnd, WM_CHAR, i, 0); //PostMessage i       
        PostMessage(hWnd, WM_KEYDOWN, 0x0d, 0x1c0001); //Press Return       
        Sleep(1000); //System.Threading.Thread.Sleep       
        if ((i % 4) == 0)       
        {       
            Execute(); //My Code Block to execute after i tries 4 times.       
        }       
    }       
}  
</code></pre>
