Click at found image works intermittently

Hi Friends,
I'm trying to create keyboard shortcuts for the many places where Zoom doesn't offer any. I want to launch the polling feature, and it seems the best way is to use click at found image. Sometimes when I readjust the fuzzy slider, it works again, but then stops.
image
I'd also like to engage the launch button once the polling window has opened. But this first part is more important.
Thanks!

Your macro is setup to look for that image in the front window. If Zoom is not at the front when you trigger the macro it will not work. You would need to recall the appropriate Zoom window first, and then perhaps insert a “pause until X window is at front” that way it looks for the image in the correct window.

Also, I have much better success using “best” instead of “unique” images.

If you need further help, let me know. I have a number of custom macros I built for Zoom, some of which do use found images (since Zoom’s AppleScript integration is poor) and they work very reliably. I can share some with you tomorrow once I’m back at my desk.

1 Like

For all the years I've used Keyboard Maestro, I've never been able to get 'click at found image' to work for me. I've heard lots of other people use it, so I know it must be User Error, but I'd be glad for any tips/suggestions, because at this point I've just given up on a potentially useful aspect of Keyboard Maestro.

1 Like

Tips:

  • Set the slider to about ÂĽ to the left. Too much to the left and it’ll fail.
  • Use “Best” as the setting
  • Capture a large enough image so it’s easier for KM to rule out duplication
  • finally, use Areas!

In which app or apps do you need assistance @tjluoma ?

1 Like

Honestly it just takes some playing around with it to get the hang of it. I had a lot of trial and error for awhile until now I can essentially set up a find image action on the first shot. For what it’s worth, don’t place images in the image well. Have the image action read the image from a file because that will keep the editor running more smoothly.

As for tips, higher resolution screens help because your images are clearer which makes it easier for KM to recognize them. You always want to narrow down the search scope as much as possible too. So indicate which window or even area (as defined by screen coordinates which can be grabbed from the mouse utility) to look for the image in. Play with the fuzzy slider and turn on the display option to see when KM recognizes the image.

That being said, if you want to post an example of something you’re trying to accomplish with it, that would help us give more specific advice.

I don’t use found image all that often but when I do, it’s an extremely useful tool. I encourage you to keep trying!

4 Likes

I have an action which clicks an image in Preview (the "sketch" icon in the Markup toolbar). It works when I set it to "front window's screen" but not when set to "the front window". Given that it does work, I'm not sure it matters much but I find that puzzling. Is the toolbar not regarded as part of the window, perhaps?

1 Like

I have found that using front window for found image actions is finicky, however I'll be the first to admit that it is more likely my lack of understanding as opposed to any issue with Keyboard Maestro itself.

That being said, I think that for found image actions to work in the front window of X application, then that app has to be active and that window has to be at the front. So if for some reason some other app or window is in focus when the macro triggers, it will fail....

I just checked the wiki for found image condition and this is what is says:

  • Alternatively, you can search within a specific window.
    • However, the window must be in the frontmost, active, application, in order for it to be seen by this Action.

So double check that the app and window you want to search for the image in is really front and active when the macro triggers. Report back and we can go from there.

1 Like

It is. The macro is in the Preview group and the window is the frontmost.

1 Like

Interesting. The toolbar is part of the front window so it should work. Would you be able to post your macro or at least a screenshot so it can be troubleshooted?

Of course. It's really simple: all I want is for cmd-shift-a not only to show the toolbar but also to select the scribble tool, as I use it all the time to mark up reports which are usually scanned. I use a large image as it seems to work better than just using the icon itself.

start markup.kmmacros (19.4 KB)

Ok so on my machine, it's returning probably 10 or 12 different results, this is probably why the macro is not working reliably, the image itself is not unique enough for Keyboard Maestro to pick the right one from all the other gray space in Preview.

A couple of suggestions, use a slightly larger image, perhaps taking in the icons to the left and right of the scribble button. This will likely be more reliable as it has a larger image to search for and will return less results. For instance, you could use something like this:

Screen Shot 2021-09-05 at 10.44.56

If you do it this way though, if you ever rearrange your toolbar you will likely have to update this image.

Another suggestion, instead of a pause for .5 seconds, try pausing until found image appears, using the same image, that way the macro will continue to execute as soon as the buttons appear.

I've made a few adjustments to the macro...try it out and see if it works for you.

start markup (for export).kmmacros (36.5 KB)

EDIT: Here's another way to do it...if you're interested. You could use AppleScript to show the markup toolbar, then click that button. Below is the script if you want to try it out. It works quite well for me but as with any script you would need to test it on your machine.

----------------------------------------------------------
# Author:		Chris Thomerson
# Version:		1.0
# Created:		Sunday, September 5, 2021
# Modified:		Sunday, September 5, 2021
# macOS:		Big Sur 11.5.2
# I claim no responsibility nor guarantee compatibility
# As with any kind of custom scripts, these must be tested thoroughly on each person's device
# May be used and distributed freely
----------------------------------------------------------

tell application "System Events"
	if menu item "Show Markup Toolbar" of menu 1 of menu bar item "View" of menu bar 1 of application process "Preview" exists then
		click menu item "Show Markup Toolbar" of menu 1 of menu bar item "View" of menu bar 1 of application process "Preview"
	end if
	delay 0.5
	click checkbox 1 of toolbar 2 of window 1 of application process "Preview"
end tell
2 Likes

Your version doesn't work at all on my iMac: it times out at "pause until".

However, your AppleScript works a treat! Thanks.

You're welcome.

Regarding the found images, that's the downside to using them...they are very dependent on each person's screen resolution and other settings. So pretty much any time you import somebody else's macro that uses found images, you need to provide your own images that way the colors and resolution in the actions will match what your screen produces.

@kikashi I use this in Big Sur to select the Sketch tool:

image

Screen Shot 2021-09-05 at 10.02.06 AM

Edit: Nervemind, didn't read the one by @cdthomer worked

Similar idea. Pure AS run by FastScripts seems to be quicker: I think it’s something to do with precompilation of the script. It’s been discussed in this forum before.

1 Like

Yes precompiled scripts are faster as Keyboard Maestro doesn’t have to do that on the fly. FWIW I always run my scripts as script files, but when I share them here (which I just barely started doing because to be honest I'm a rookie with AppleScript) I just paste the script itself so others can use it how they want.