Sign in to follow this  
Followers 0
OnlyForMe

Optimize Loop

5 posts in this topic

Hi, I managed to get everything working with VB and AutoIt, and now I wish to work on performance. In VB, I do this:

Do
PixelSearch(500,450,500,450,&HFFFFFF,0,1)
Loop Until AutoIt.Error = False
MessageBox.Show("The pixel has been found.")

 

Ok, it all works fine, however the speed is a bit floppy. I'm guessing it's because of the loop. It's an infinite loop that is spiking my CPU, etc. I did put Thread.Sleep in the loop, and it helps a little, but not very much at all. Is there a way to optimize this loop for speed? What I"m doing is scanning my desktop for one pixel and then reacting with another function once the pixel is found. (When I press my button, the pixel is not there, so it's an infinite scanning loop until the pixel appears, then my program reacts). The program runs for no more than 1 second by the way. The pixel I'm looking for always appears within one second.

Thanks!

Share this post


Link to post
Share on other sites



JohnOne, he already said he tried adding a sleep. That's not the problem.

PixelSearch is inefficient when you have Aero enabled. This may be what you are encountering.

Share this post


Link to post
Share on other sites

That function is the same as native Sleep function in C++.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0