Script too slow to react and high cpu usage on find image

I want to use keyboard maestro to detect a certain string of text within a game application almost instantly and then react with a single keypress. I wrote a script which quickly repeats a scan for the small screenshot of the text every 0.001 seconds or so and if it is found then keypress and break for a few seconds. the script isn't fast enough and when I watch it back on a screen recorder it simply does not detect (according to the "display" on image find feature) and react fast enough. the script also puts my cpu over 100% for a prolonged period. the reaction time needs to be extremely minimal like a small fraction of a second.
so Is there a more efficient and effective way around this issue? Thanks

Unless there is no other drastically improved suggestions, it would be much more effective if the find image on screen feature would only scan a small designated area.

(Edit: just found this feature.)

Hey Tobias,

As you've noted that feature exists, so let's demonstrate where for future users:

Find Image on Screen.kmactions (736 B)

-Chris

The Pause 0.001 seconds is pointless, Keyboard Maestro only executes actions that fast anyway.

Image Searching is incredibly CPU intensive, as you have noted. Unless you can limit the screen area to a small area, it will take way longer that 0.001 seconds.

If the image always appears in a single location you might be able to use the Pixel condition instead.

But even so, keep in mind that Keyboard Maestro is not designed as some sort of Real Time Operating System (RTOS). It is designed to perform tasks significantly faster than you, but that is a long way from 0.001 seconds!

1 Like