Jump to content

Optimize Loop


OnlyForMe
 Share

Recommended Posts

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

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 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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...