{"id":36024,"date":"2022-05-31T15:17:43","date_gmt":"2022-05-31T19:17:43","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=36024"},"modified":"2022-05-31T15:17:43","modified_gmt":"2022-05-31T19:17:43","slug":"activating-applications-via-applescript","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2022\/05\/31\/activating-applications-via-applescript\/","title":{"rendered":"Activating Applications via AppleScript"},"content":{"rendered":"<p><a href=\"https:\/\/daringfireball.net\/2022\/05\/wonder_twin_powers\">John Gruber<\/a>:<\/p>\n<blockquote cite=\"https:\/\/daringfireball.net\/2022\/05\/wonder_twin_powers\">\n<p>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.<\/p>\n\n<p>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 <a href=\"https:\/\/developer.apple.com\/library\/archive\/documentation\/LanguagesUtilities\/Conceptual\/MacAutomationScriptingGuide\/index.html#\/\/apple_ref\/doc\/uid\/TP40016239\">JavaScript for Automation<\/a>[&#8230;]<\/p>\n<\/blockquote>\n\n<p><a href=\"https:\/\/twitter.com\/petermaurer\/status\/1531635687686082562\">Peter Maurer<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/petermaurer\/status\/1531635687686082562\">\n<p>I&rsquo;m voting for bug. Here&rsquo;s why: <code>NSRunningApplication<\/code> has the exact same problem, where <code>NSApplicationActivateAllWindows<\/code> isn&rsquo;t being honored. Started at around macOS 11.4, if I remember correctly.<\/p>\n<p>Bonus fun fact: Earlier macOS 11 versions had the inverse bug, where activating apps via <code>NSRunningApplication<\/code> always behaved as if <code>NSApplicationActivateAllWindows<\/code> were set. Looks like they then attempted to fix it, overdid it, and then never got around to revisiting the problem.<\/p>\n<p>The only way (that I&rsquo;m aware of) to get the correct behavior is using <code>SetFrontProcessWithOptions()<\/code>, which is deprecated. Sigh.<\/p>\n<\/blockquote>\n\n<p>Previously:<\/p>\n<ul>\n<li><a href=\"https:\/\/mjtsai.com\/blog\/2020\/01\/09\/front-and-center-1-0-1\/\">Front and Center 1.0.1<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2022-05-31T19:17:45Z","apple_news_api_id":"c8b90865-9c31-4bb3-aa57-d3ef6ec0648b","apple_news_api_modified_at":"2022-05-31T19:17:46Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AyLkIZZwxS7OqV9PvbsBkiw","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[2],"tags":[159,131,30,1666,2077],"class_list":["post-36024","post","type-post","status-publish","format-standard","hentry","category-technology","tag-applescript","tag-bug","tag-mac","tag-macos-10-15","tag-macos-12"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/36024","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=36024"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/36024\/revisions"}],"predecessor-version":[{"id":36025,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/36024\/revisions\/36025"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=36024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=36024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=36024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}