Click whenever a specific image appears

Hi :slight_smile:

I'm wondering if it's possible to set an action which would be able to execute at any time during a macro if a specific image would show up ?

For example, it could be based on an image condition like this:

  • If at any moment of my macro, the blue button "OK" showed up, then the macro should click on it

I have a box on Firefox which appears time to time but I cannot predict when it will appears as it is very random. In that sense, I would like to prepare an action to click on the "OK" button of this box whenever or if it shows up.

How could such a thing could be implemented ? :thinking:

A macro (and hence an action) can only start running in response to a Trigger. And there is no trigger to detect when an image shows up on the screen.

You could start a second macro asynchronously (using the Execute a Macro action, configured to execute the macro asynchronously) and it could do a Pause Until action and pause until the image appeared or the parent macro finished (indicated by setting a variable). But that is about as close as you can get. And it would be expensive in CPU while it was running (which could be mitigated a bit if you are willing to allow some extra lag on finding the image, by using an Until loop with a Pause action within it).

@peternlewis has provided you with a workaround, but be advised that such a solution is likely to use a very high percent of your CPU. Of course, the way to find out is to test it with the Activity Monitor open.

One way to minimize the CPU usage is to restrict the search area of the Found Image condition to as small an area on your screen as possible.

Thanks to both of you @peternlewis & @JMichaelTX !

Indeed, I first try a "pause until" action but sometimes, the specific image never showed up which caused my macro to wait undefinitely. Thus, I've observed that the specific image I was looking for would appear between 30 to 45 seconds wait after the previous action has finished. In that sense, I changed the "pause until" to a "pause for 55 secondes".

I've just figured out something concerning my original request.

A little bit of context:
I had a popup which would appears or not at a random time on my screen after a specific step. To move on the next action I need this popup to disappear. The issue is that I was not sure if the popup would appear or if it does, when it would appear.

The solution:
I set the action "pause until" + found image condition. On this action I set deactivate the Timeout abort macro and I set the timeout to a specific time (in my case I only need 55 secondes before timeout). After this action, I just put an "if..." action in case the popup would appear, if not, no action and the macro can proceed.

I hope it'll help you :slight_smile: