Tuesday, May 31, 2022 [Tweets] [Favorites]

Activating Applications via AppleScript

John Gruber:

On MacOS 12 Monterey (and apparently MacOS 11 Big Sur), what happens instead is that TextEdit becomes the active application but only its frontmost window comes forward.

On MacOS 10.15 Catalina, and all previous versions of MacOS back to Mac OS X 10.0, all of the open windows in an app come forward when you tell that app to activate in AppleScript, or with the equivalent in JavaScript for Automation[…]

Peter Maurer:

I’m voting for bug. Here’s why: NSRunningApplication has the exact same problem, where NSApplicationActivateAllWindows isn’t being honored. Started at around macOS 11.4, if I remember correctly.

Bonus fun fact: Earlier macOS 11 versions had the inverse bug, where activating apps via NSRunningApplication always behaved as if NSApplicationActivateAllWindows were set. Looks like they then attempted to fix it, overdid it, and then never got around to revisiting the problem.

The only way (that I’m aware of) to get the correct behavior is using SetFrontProcessWithOptions(), which is deprecated. Sigh.

Previously:

1 Comment

Ironically, I never noticed any of this in Keyboard Maestro because Keyboard Maestro still actively uses SetFrontProcessWithOptions (sadly despite it being deprecated) due to various other bugs in NSRunningApplication activation (bugs that are old enough that they have radar numbers (18980463) instead of Feedback numbers, sigh).

But sure Apple, deprecate the old APIs and replace them with broken new APIs, I'm sure that'll be fine.

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment