• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Javascript for automation quastions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Javascript for automation quastions


  • Subject: Re: Javascript for automation quastions
  • From: has <email@hidden>
  • Date: Tue, 16 Dec 2014 19:36:06 +0000

2551 wrote:

> Deivy's thread got me interested in looking at JXA. I don't know if you guys have seen this, but looks like a good bootstrap into JXA for AppleScripters:
>
> https://github.com/dtinth/JXA-Cookbook/wiki

The Cocoa-related info is probably fine. I've not tried that bit myself so can't say for sure, but the basic principles are much the same for all <language>-ObjC bridges, so anyone who knows a bit of Cocoa can should be able to figure it out okay. OTOH, the info on application scripting is contributed by folk with no real understanding of how application scripting actually works, so while well-intentioned don't expect much depth or accuracy as it's essentially the blind leading the blind.
Also, the wiki doesn't tell you which bits of JXA work and which are
defective or missing, or how to untangle the intentionally obfuscated
parts. e.g. I saw an example there that uses `appObj.elements[varName]`
syntax, which should *never* be used for by-name references as it's
dangerously broken. I start writing up a list of JXA defects over on a
MacScripter thread a while back
(http://macscripter.net/viewtopic.php?id=43257) which might be some
help, but if you want more then you'll really have to bug me as it's a
non-trivial amount of work to go through it all.
Incidentally, post-WWDC I urged Sal to provide an AS-to-JS conversion
feature similar to that provided by the ASTranslate tool I wrote for
appscript. Appscript users absolutely *adored* ASTranslate because they
could copy-paste almost any existing AS command and instantly get the
equivalent Python/Ruby/ObjC syntax. Incredibly useful, and takes only an
hour or two to implement via existing OSA functionality. As with other
things I got ignored on this, but it would've answered a lot of user
questions absolutely for free.

For existing AppleScripters, I'd suggest getting a good book on the JavaScript language, getting up to speed on that, then figuring out how your existing application scripting knowledge translates (or not) to JXA from there. Not sure what's best these days (there's a lot of snake oil about), but Doug Crockford's "JavaScript: The Good Parts"[1] might be a good option: like Matt N's AppleScript: The Definitive Guide, JS:TGP isn't afraid to point out the language's many problems as well as the bits that are competent.
Also, feel free to play with my JavaScript OSA component if you like[2].
It's buggy, crashy, inadequately documented, and officially unsupported,
so caveat emptor, but it's nearly feature-equivalent to AS and may
provide some insights. Plus the bundled JABDemo tool provides a crude
JS-to-AS command translator which should be good fun trying to defeat
(it doesn't like Finder and ignores osax commands, but otherwise largely
works).
Regards,

has

[1] http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742
[2] http://sourceforge.net/projects/appscript/files



_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


  • Follow-Ups:
    • Re: Javascript for automation quastions
      • From: 2551 <email@hidden>
  • Prev by Date: Re: Javascript for automation quastions
  • Next by Date: Re: Javascript for automation quastions
  • Previous by thread: Re: Javascript for automation quastions
  • Next by thread: Re: Javascript for automation quastions
  • Index(es):
    • Date
    • Thread