Trigger macro/script when a predefined image appears in a predefined location on the screen?

I’d like to automate something where I can select a part of the screen for the program to watch for, to trigger when a given image appears in that part of the screen. I looked into Keyboard Maestro but it doesn’t seem to be possible with it. Can I do this any other way?

You could trigger something to capture the screen every few seconds and then use something to check that, but in all honesty, apart from the overhead, having something “watching” some of your screen feels bad to me. It feels like a great example of a security issue.

Perhaps there is another way to achieve the same automation trigger that does not rely on monitoring your screen content? Can you share any additional information about what you want to do?