OnlyForMe 0 Posted March 25, 2014 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 1,603 Posted March 27, 2014 (edited) Import (however you do that in VB) the WINAPI Sleep function and use that. EDIT: Hold on AutoItX has a Sleep function, what is the problem with that? Edited March 27, 2014 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
Richard Robertson 187 Posted March 28, 2014 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
JohnOne 1,603 Posted March 29, 2014 It is possible that the VB native "System.Threading.Sleep" he tried is the problem.Okay, I'm not certain but I know AutoItX is not thread safe. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
Richard Robertson 187 Posted March 30, 2014 That function is the same as native Sleep function in C++. Share this post Link to post Share on other sites