Can Xojo Detect Another Application Open

I make these comments to help a future reader who might run into this kind of difficulty. Keyboard Maestro Engine is not a “regular” application. It is a background application.

Well, this “technique” requires you to know how to access the app bundle. It works for the application Keyboard Maestro itself. The Info.plist for that I can find, and it does contain the information for that app.

CFBundleIdentifier
com.stairways.keyboardmaestro.editor

However, that is the editor and not the engine. Looking around my Mac the closest thing that I could find was under the ~/Library/Preferences/com.stairways.keyboardmaestro.engine.plist

Perhaps from that I could guess the com.stairways.keyboardmaestro.engine was the right answer.

The only other hit that I could find was a cryptic comment in the Keyboard Maestro PDF Manual.

Note: The Mac App Store engine uses bundle ID com.stairways.keyboardmaestro.editor.engine instead of com.stairways.keyboardmaestro.engine for reasons only Apple can explain.

This comment itself suggests that these things are not always straightforward. :slight_smile:.

I am glad this discussion pushed me far enough down the rabbit hole that I ran across this nugget. It would have been a hellish bug to figure out with different users having different experiences.

If you have different apps then you have different bundle ids. You must locate the apps and then peek into the bundle.

Using PrefsEditor from Thomas Tempelmann should show all apps that have preferences including their bundle ids.

2 Likes

That is useful. You cannot find KeyboardMaestroEngine using the Finder. But if you look through the list that PrefsEditor produces, you can see

com.stairways.keyboardmaestro.engine

in that listing. The listing in that program seems to be primarily (?always) the bundleIDs.

It is very similar to the list seen in

~/Library/Preferences where you will see the extension .plist but otherwise basically the same.

Hi Robert,

I found the engine as a helper app inside the main Keyboard Maestro.app

  1. Select Keyboard Maestro.app
  2. Right-click, Show Package Contents
  3. Navigate inside Contents
  4. Navigate inside MacOS
  5. This is where I found Keyboard Maestro Engine.app

And then it appears you do know how to find the identifier in the Info.plist

Apple Script will be relatively problem free for you when building your tool locally in debug mode. If that’s all you plan to do with that application then Apple Script can work for you! The problems affect your app once it’s released.

You’re not wrong - that’s pretty much what declares are. Declares let us use system APIs that are not available in the Xojo framework. It’s part of why declares are a better solution than Apple Script. Declares are direct access to the correct Apple approved ways of doing things, while Apple Script is an interpreted scripting tool with finicky permissions.

Best,
Tim

2 Likes