Is it possible to set up the "Click at Found Image" action (or to string together multiple such actions) so that a second image is searched for if (and only if) the first image is not found?
Thanks in advance!
Is it possible to set up the "Click at Found Image" action (or to string together multiple such actions) so that a second image is searched for if (and only if) the first image is not found?
Thanks in advance!
Yes, if I understand what you mean, you can add multiple "Images" to a given action. Here is an example:
If one image is not found it goes on to the next.
In this example the search area is also constrained to specific coordinates.
The click is accomplished by saving the "FoundImage" coordinates as a variable (in this case a "local" variable) and using it in a "Move/Click Mouse" action:
Thanks, @rcraighead! I think I understand what you've laid out. Any chance you can you share the full macro so that I can study it more closely? Or is this pretty much it?
Yes. To directly answer your question, use a If Then Else action with a Found Image condition.
When KM finds an image, the image coordinates are returned in the FoundImage token, which you can use in the Move or Click Mouse action.
Got it. Thanks, @JMichaelTX! Will try to set this up tonight.
@JMichaelTX, my experience is that using "Pause until: any of the following are true" works without the need for multiple "if then" actions. What is the downside to this approach?
Nothing in general, but the OP asked about only two images. So in that case a simple IF/THEN is more efficient.
Also, with the multiple "any" image, you don't have a way of setting a preferred image. This may also consume more resources since KM is constantly looking for multiple images.
@JMichaelTX, Thanks. I've updated my macro based on your comment.
It's not really necessary to use a conditional. Simply set the actions so that failure doesn't abort or alert. Use as many sequential actions as necessary (each with a different image). All but one (or all) will fail, which will simply make the macro proceed to the next action. If one is found, the image will be clicked. The macro will proceed in either case. I've been doing this for multiple macros for some time.
So if you are not doing any IF testing, then KM will aways search for ALL images, even if it finds the image on the first case. Seems like that could slow down the macro. I see no reason not to use IF/THEN or Pause Until any so that as soon as KM finds an image it stops searching.
That would likely be true if you strung together a thousand actions. For a handful, I suspect the conditional would actually be slower, but there's no perceptible lag in my uses, anyway.
I don't see how that is possible. Executing an IF/THEN on the results of the found image attempt is surely measured in the micro seconds, if not less. Whereas searching your screen for some image is much, much slower. Of course it depends on if you are searching all screens, a specific screen, or a limited area on a specific screen.
Having said that, I am continually amazed at how fast the KM find image works. This is a real credit to the programming genius of @peternlewis. This is one feature of KM that can't be duplicated by any other tool, AFAIK.