OnlyForMe Posted March 25, 2014 Share 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! Link to comment Share on other sites More sharing options...
JohnOne Posted March 27, 2014 Share 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. Link to comment Share on other sites More sharing options...
Richard Robertson Posted March 28, 2014 Share 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. Link to comment Share on other sites More sharing options...
JohnOne Posted March 29, 2014 Share 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. Link to comment Share on other sites More sharing options...
Richard Robertson Posted March 30, 2014 Share Posted March 30, 2014 That function is the same as native Sleep function in C++. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now