1

When calling an application using JXA (JavaScript for automation), you can refer to the app by the bundle name or by the identifier, just like in AppleScript:

tell application "TextEdit" to activate
tell application id "com.apple.TextEdit" to activate

are equivalent to

Application('TextEdit').activate();
Application('com.apple.TextEdit').activate();

But in AppleScript one can also call an app by the bundle signature, which is often version-invariant and stable over time:

tell application id "ttxt" to activate

What is the JXA equivalent of this latter call? How can one create version-independent JXA scripts?

retrography
  • 6,302
  • 3
  • 22
  • 32
  • 1
    according to the documentation, you should be able to reference by just using the bundleID - https://developer.apple.com/library/archive/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/Articles/OSX10-10.html#//apple_ref/doc/uid/TP40014508-CH109-SW6 – Mike Diglio Sep 03 '19 at 18:12
  • 1
    Did you ever quickly tried `Application('com.apple.TextEdit').activate();`? However the *FourCharCode* identifier seems to be exclusively related to AppleScript. – vadian Sep 03 '19 at 18:12
  • @MikeDiglio and vadian are right. But the main issue I have (having a version-independent handle) does not get resolved using your solution. I assumed calling the identifier and the signature would follow the same syntax under JXA, but that is not the case. I edited the question to reflect the issue. – retrography Sep 03 '19 at 18:25
  • Which application uses different bundle identifiers for different versions? – vadian Sep 03 '19 at 18:47
  • 1
    @vadian Turns out some of my most beloved and most heavily scripted apps: com.devon-technologies.think3, com.phaseone.captureone12, com.stata.stata16, com.flexibits.fantastical2.mac. – retrography Sep 03 '19 at 19:49

0 Answers0