Macro Groups and Active Window Detection

Hello... First time poster here. Been using KM for about 2 years. KM9 latest version. macOS 10.15.7. I've been pretty successful in creating binds for hotkeys that are associated with specific applications, windows, or "all others" actions. But I'm at a loss in this instance, tried as I might.

There's an app that I use, purchased from MAS, called "Contacts Sync Pro" [v8.1.2]; It works well for automated 2-way sync of contacts to/from iCloud/Gmail. Been using it for many years. The problem is that this application runs only in the taskbar. It does have standard Windows that open in certain instances, but I don't think they're true Windows but extensions of the taskbar icon. (Best guess, not having delved into XCode too much) As such, when I attempt to create a Macro Group with associated filter, I'm unable to achieve a functional filter. Whereas the CSP does have a working, disconnected/resizable/movable Window, KM isn't able to detect it with any of the filters -- even having specified the .app directly. I was able to manipulate the app via both of the following:

  • Resized the window by means of "Move Front Window to Position".
  • Activated (not launched) a previously backgrounded window by means of "Activate Contacts Sync Pro"
  • Confirmed that KM can not see application windows as "Front Application Window" by means of this macro: List Windows Keyboard Maestro Can See v1.1

Other items that failed to work:
"Activate only when focused window title contains 'Sync' " (see window screenshot attached, hopefully)
"Available when these applications are running: Contacts Sync Pro" (technically this works -- but this needs to remain 'running' at all times in order to auto-sync in background!)

Workaround that I'm currently using successfully is:
"Activate/Deactivate when corresponding status menu entry is selected" -- thus requiring a couple of extra clicks before and after using any of the macros in this group.

(Notice in screenshot that the menu bar shows 'Numbers'. This isn't an ID-10-T error... -- at least not this aspect of this post! Numbers was simply the last active window prior to Contacts Sync Pro. This is what leads me to infer that this is some special type of window...)

Any thoughts as to how I would be able to limit a Macro Group to being functional only when this application's window is active and/or open?

I have a couple of ideas. But I'm not one of the experts here, so feel free to ignore me - I won't be offended. I already admit from reading your post that you are smarter than me.

If the only problem is figuring out when the app is visible, that's not really a tough problem. We can see with our eyes when the program is open, and that's all you need, because KM has more than one way to read the screen. It can search by images or by text. The text searching will improve dramatically under Monterey.

Once we decide on a method of detection, then, until you say or ask otherwise, you will be on your own to control that app. At this point in time I have no idea what you want to do with the app.

I also want to know if you are executing the macro when you are AFK or when you are in front of your keyboard. If it runs primarily when you are AFK then we don't have to worry too much about speed. We can take minutes instead of seconds, for example.

So what I would do, based on what I know so far, is create a macro that starts up once per minute. The first thing it would do is check the macOS list of processes and abort if CSP is not in the list. The second thing it would do is either (a) read the text on the screen looking for keywords such as "Confirm Sync", or (b) use an image search action looking for that big sytlized "X" button on the window. If it finds one of those, it passes control to a KM macro that solves whatever problem you want. If it doesn't find those it goes back to sleep.

Is your Mac an M1 Mac? Can you wait for Monterey? I find the OCR ability on M1 with Monterey to be astoundingly fast and accurate. OCR will also work on Intel Macs but I have both types of Macs and I find the Intel one to run hot when doing frequent OCR.

Lastly, open the macOS app called Script Editor and see if there's a dictionary visible in that app when you are running the app. If so, we may be able to use that to determine when that app is running and/or visible. That would probably be the smartest and most reliable tactic to solve this. But I have no idea if it would have an AppleScript dictionary. It's 50-50. If it has one, then probably some of the AppleScript experts on this site can give you further advice. There may be a variable that indicates when the app is visible. That would be more reliable than my other suggestions above. But my suggestions would still work.

Hey Joshua,

You can't.

You can probably detect the window with AppleScript, but it would be a hassle to work around all the possible open apps when your Contacts Sync Pro window is open.

What you might try is creating a simple AppleScript application with a name similar to “Contacts Sync Pro”.

Then use a macro to always launch it before you work with your actual Contacts Sync Pro app.

Bind the macro group to the AppleScript app, and you have a pseudo macro group for Contacts Sync Pro.