Being able to locate images on our screen is a huge benefit when automating things, but in reality, we have to deal with timing.
waitFor is here to help by allowing us to specify a timeout in which we expect our template image to appear on screen!
Let's tweak the snippet used on find just a little:
waitFor basically does the exact same as find, but multiple times over a specified period of time.
It'll scan your main screen for the given template image, but if it fails to find it, it'll simply give it another shot. The interval in which these retries happen is configurable as well.
In the above snippet, we tell
waitFor to look for our template image for at most five seconds, retrying every second.
Everything mentioned on find applies to
waitFor as well.
Action timed out after 5000 ms
waitForwill repeatedly search your main screen for the template image and if it finds a match, it'll return the Region it located the template image in.
- If it can't locate the image, it'll retry the search in configurable intervals until it hits the configured timeout in milliseconds.