Comment by _8ljf
6 years ago
Funny enough, back when the Mac Automation devs were still getting JXA ready to throw away, one of the things I told Sal Soghoian to do was to add automatic AS-to-JS syntax translation to Script Editor’s Log pane. While it only translates outgoing Apple events, not native AS code, 99% of the time JS users already know how to write general JS code, and it’s the application-specific references and commands they’re struggling to form.
Back when appscript was still a thing I hacked together a quick-n-dirty AppleScript-command-to-Python/Ruby/ObjC translator app which appscript users absolutely adored, plus it greatly reduced the number of “How do I…” support questions because, more often than not, users already had a working example in AppleScript which they could just run through the translator to get the answer for themselves.
Needless to say, Sal Soghoian completely ignored my expert recommendation for this killer feature which could be implemented in a day, choosing instead to dump JXA and its few hapless users down the same black hole of nothingness as all his other product failures. PEBKAC. Not Invented Here. So it goes.
--
[edited to add]
Just d/led the JavaScriptOSA zip from the appscript project page on SourceForge, and the bundled JABDemo.app still works. It’s not codesigned so you’ll have to right-click the app to Open it, overriding the security warnings, but it still works even on 10.15 (caveat any bugs in the underlying JavaScript Apple event bridge, of which there were a few, plus the endless string of permission requests whenever you try to control another app). Example:
Original AppleScript commands:
tell app "textedit" to get name of document 1
tell app "finder" to count every folder of home whose name begins with "D"
Generated JavaScript equivalents:
app("TextEdit").documents.at(1).name.get()
app("Finder").home.folders.where(its.name.beginsWith("D")).count({each: k.item})
I mean, I wrote the thing and even to me years later it’s still like freaking voodoo! :)
No comments yet
Contribute on Hacker News ↗