Click on One of Many Possibly Found Images

I'm trying to click on a found image, but the problem is that the image changes slightly and randomly, enough to cause image detection to fail. I can handle each image variation with a new try/catch block, but this quickly becomes unmanageable as they become deeply nested. Is there a better, cleaner way to accomplish this?

Tried increase fuzziness?

The image I'm matching is text, and it changes in color, case, kerning, and other things I can't catch with the fuzziness control.

What application is this being done in? Clicking via image is something I generally save as a last resort.

If browser it should be done via JavaScript if possible. If application, we should look to see if there are other ways to try to click it or tab to it.

Please check out Tip: How Do I Get The Best Answer in the Shortest Time?

1 Like

It's in Google Chrome. Do you have an example I could crib off of to do this?

Nice!!! Browser is probably the easiest in my opinion. Check out a recent related thread at What do I need to learn to "Push a "button" on a Safari page

The problem is that it's a dynamically generated box of text, so I can't just look at the source and find an ID for it.

Also, there may be several of these onscreen at once, so I'm targeting the rightmost one from my vantage point.

Dynamically generated pages typically isn’t a problem. Instead of viewing page source we need to inspect the rendered elements. Do you have a link to the page you are working on targeting? Have you used the Google Chrome dev tools before to inspect elements on the page?

It's just YouTube, with the text being what appears after you select not interested. I don't know the dev tools well enough to inspect dynamic elements of the DOM, no. I'm not a web developer, so I only know bits and pieces.

No worries. We can totally help with that. I’m not familiar with selecting “not interested” on YouTube. Do you have an example screenshot or better yet a link to a YouTube video page the exhibits that behavior?

Sure, here's where the not interested text appears after clicking the 3 dots:

...and here's the tell us why text that I want to select, but which continually changes color, case, kerning, size, and probably more:

Screen Shot 2022-10-08 at 3.53.21 PM

AAAH! That makes more sense. Thanks. So are you trying to have your macro click not interested and then click tell us why?

Yes, that's right. The object here is to attempt to train Google/YouTube to recommend what I want to watch by giving feedback on things I don't like. It seems to work at least a little bit, although it's far from perfect. I haven't done any science on this, but YT seems to take my feedback more seriously when I provide a lot of it repeatedly, which is why I created a few KM macros to manage this and save my clicking finger some presses.

Here is how I would solve that cool idea...

Screenshot of macro

I'm using JavaScript to click on each menu item except for the first.

I left the pause actions in there even though they weren't needed for me just in case someone needs more delay between each action for it to work on their machine.

Remove YouTube video from recommendations list.kmmacros (49.6 KB)

I'm using the action:Trigger Macro by Name [Keyboard Maestro Wiki] to run the macro without moving my mouse.


Thanks so much for this help! Now that I know you can use Javascript like this, hopefully it will help me with making future macros too.

1 Like

Works perfectly too!

1 Like