Macro Can't Find a Certain Image

I'm using a video software that, unfortunately, doesn't use the top menu bar like any other application (go figure). The menu is embedded in the project window itself so I have to rely on the action "Click at found image".

I am able to make it run until the last step. It worked maybe twice, but then 99% of the times, it says there's no unique image. Here's my macro:

Screen Shot 2022-04-17 at 7.23.39 PM

Here's the menu. The option I'm trying to click is the "In-to-Out Area" (before you ask me why I don't just click the shortcut, that's because, for some reason, that shortcut sometimes works, sometimes it doesn't. I guess it's a glitch that they need to fix).

Screen Shot 2022-04-17 at 7.23.18 PM

This is the image I'm using to trigger:

4 - finally here 46 12

I tried different values of blurriness to see if that was the issue, no luck.
It's so weird, because all the other images have the exact same settings and they are working.

Error message:

Screen Shot 2022-04-17 at 7.27.46 PM

Can someone help me with this? Am I missing something?

Thank you :slight_smile:

1 Like

When I've run into this sort of problem, switching from "Unique" to "Best" in the popup menu has gotten the action to work. No guarantees, but it's worth a try.

3 Likes

Thanks for the tip and I will remember that in the future.
I was able to make it work changing it to Best and also increasing the blurriness up to half.
Since this is a task that really needs to work every time without stopping, I changed the macro to use the "Move or click Mouse" and used the absolute position of the mouse based on the screen. I just have to make sure the window is using the full screen.

Again, thank you for your suggestion and I will remember that when that issue comes up again :slight_smile:

You probably know this, but... If the menu is always in the same place, you could simply click at an absolute coordinate or one relative to the front window's corner.

What software is it? You might be able to try AppleScript.

1 Like

When I mentioned the top menu was more about using the "Select or Show a Menu Item", which would be way more accurate if, for example, the window was not 100% full screen, or was moved to a different position (I see now that I can use that relative position based on the front window as well, which is very interesting).

By the way, what is the "absolute" position related to?

I'm still learning how KM works so I'm still trying to understand what each action does and all that, but I'm amazed at how much time this will save me! I've heard about the program a long time ago, but never really did my research. I thought it was really just a program for simple shortcuts, not a super complex automation tool :slight_smile:

The video software I'm using is HitFilm Express:

Screen Shot 2022-04-17 at 9.39.05 PM

I'm not comfortable at all with AppleScript. I can look at it and sometimes understand the logic behind it (based on my super, hyper basic understanding of JavaScript), but building something from scratch, I just can't.

I was assuming that each menu item would have some kind of "code" associated with it and maybe through AppleScript I would be able to trigger it, but again, that's too complex for me...

Does the same flakiness apply to the Option-Q shortcut? If that always works, triggering it that way could be a better option.

The entire screen.

Check out UI Browser. You can try the demo version and grab a code to click the menu. It may or may not work if screen elements move dynamically.

That's what I thought, but then what's the difference between that and the "main screen's left corner" option? Wouldn't that be the same? The absolute position is relative to the top left corner, right?

"Funny" enough, the application will stop being developed/supported...
But I will see what I can do with the demo version. Thanks for the tip :slight_smile:

It makes a difference if you have multiple screens.

1 Like

Oh I see. So with multiple screens the Absolute would probably think of all screens as a single screen, while "main screen's left corner" would only use the main screen (for example on a laptop would be the screen that comes with it, not the external screens). Right?
Thanks for clarifying!

1 Like

I can't give you a technical explanation on how Mac keyboard short cuts work and how Keyboard Maestro simulates them, perhaps one of the KM gurus can, but I can suggest a working solution. As you may have guessed already, it's going to involve AppleScript...

I'm assuming that we can't trigger "Option-Q" with a KM keystroke step because that shortcut is user-defined within HitFilm Express. But, rather than look for images and simulate screen clicks, you can simulate typing those keys. Here's the KM macro:

HitFilm Test.kmmacros (1.8 KB)
HitFilm test

Your workflow suggests that you'll always have HitFilm as the frontmost app when running this, so I haven't bothered activating it, etc.

Works for me every time -- let us know how you get on!

1 Like

Thanks for this workaround.
I will try this, but the issuw with HitFilm is that I have some projects that sometimes take a few seconds (like 30 or so) to start accepting shortcuts such as the one to add a project to the queue. Go figure...

So I need to figure this out and if I understand what's happening with those projects and fix them, I will probably be able to use your script. Thank you so much!

In not possible to create a menu action instead of click at found image?

@hispanicus unfortunately, as I mentioned on my original post, this app does not have a "normal" menu like the other apps that can be accessed via KM's menu action. The menu is on the window itself. The only option is to do it via AppleScript as someone else suggested. I haven't tested it yet though so I can't confirm it works.

Anyway, as I also mentioned, there are some projects I have for that app that sometimes don't accept shortcuts for a few seconds, so it would lead to the macro being interrupted, so for now the only viable option is the click via the Found Image

1 Like

You know you can set it to use "normal" menus in the app's Preferences, don't you? :wink:

That doesn't actually solve the problem though (it's the first thing I tried), and I think it's because "Option-Q" isn't a normal shortcut -- it's user-defined within the application, which is why it isn't available to KM's keystroke step but is to System Events. Putting the menus in the menu bar might give you a consistent location for clicking, though -- no found image position required!

The AppleScript certainly works on a trial download of HitFilm, but that was with their small demo projects -- you may have include a "wait until..." of some kind until your large projects fully load. Again, I'd assume that the delay in their being available is something to do with them being user-defined and, somehow, at a different "level" in the events hierarchy to "built-in" shortcuts like Command-O.

1 Like

I actually didn't know it haha Just changed it. Thanks for the tip. This app is so different from other apps on so many things that I thought this was another one of those "special features"

The issue was not so much about the position of the image, because the mouse was following the right path and all that. The issue was fixed once I changed to "Best" on the Found Image action.

The issue here is not so much about the project being loaded, because they are and I can see the shortcut and even click it. The issue is that the shortcut itself doesn't work for a few seconds. What I mean is: using the keyboard shortcut, doesn't work for a few seconds, but if I open the project and use my mouse, the action from that shortcut works as expected. Hope it makes sense. I have the same issue with the space bar where the project doesn't play while using the space bar, for a few seconds. Then suddenly, it starts working again. So there's really nothing that could trigger the "wait until...", because there's nothing that needs to be loaded.

For now, using the Found Image set to Best, is the best option until I find why some projects behave that way when it comes to the shortcut and the space bar...

Thanks again for the tip about the top menu :wink: