How to check "Screen contains image" against image in a file?

I quite frequently use the ’Screen contains/does not contain’ condition (to make actions depended on what’s on the screen).

Sometimes I want to check for one of, say, 5 or 6 images. The if then logivce becoems a bit unwieldy. For maintenance it would help a lot if instead of pasting an image in the editor I could say _”Check ‘Screen contains image from file’ at a given file path”_.

Can I do this? And how? - Many thanks for your help in advance.

Absolutely! Just click image and select "File:" from the drop down menu

1 Like

That’s cool. Thanks.

How can I use in this file path variable tokens?

I tried ~/KM/detect_me/Screenshot_%Variable%cnt%.png (while I have an image at ~/KM/detect_me/Screenshot_2.png and I have set the variable cnt to 1).

But the image is never found on the screen.

The field is a token field, so tokens work exactly as any other token field:

If it is failing to find the image, it is either because the resulting path is incorrect, or the image in the file is not correct (DPI images or other problems perhaps?).

2 Likes

Using file paths doesn't necessarily change the logic -- you can do "any of these images" in a single "If" Action:

Using paths to images will reduce your macro plist size, but at the expense of having to spend time reading in all those files when the macro runs.

Unless you want to do a looping test? Something like:

Neater in the Editor, but will run slower than the previous method. Plus you can't set a different search area or fuzziness for each image, which could cause problems.

1 Like

Thanks for confirming. I had an error in my %Variable%... syntax...

1 Like

Exactly that!

Yes, I was thinking it might be easier to maintain image sets in folders (for different resolutions and my two different Macs), but let's see how I go with it.

1 Like