Re:JavaScript for OS X Automation
by rikkus on Wednesday September 17, 2014 @08:20AM
(#8329586)
Really not sure what the point of either of these would be, could you fill in more of a real word example?
[ Parent
| on HN ]
Re:JavaScript for OS X Automation
by matthewmacleod on Wednesday September 17, 2014 @09:27AM
(#8329800)
That looks pretty straightforward - it retrieves a list of messages from Mail which have a particular subject. Presumably you can then perform actions on them.
The problem is the Javascript language requires you to import the Cocoa stuff
ObjC.import('Cocoa')
And then you get stuff like
task = $.NSTask.alloc.init task.running == task.isRunning
The AppleScript version
if application "iTunes" is running then --- Do stuff... end if
It may just be me, but in some cases the AppleScript version is easier and better.
Re:JavaScript for OS X Automation
by linguafranca on Wednesday September 17, 2014 @09:56AM
(#8329932)
I think you're misreading the document, I don't think you actually have to instantiate an NSTask in order to compare whether another application is running. You would just do something like this:
Mail = Application('Mail')
if (Mail.isRunning) { ... }
Re:JavaScript for OS X Automation
by oatmeal_coffee on Wednesday September 17, 2014 @11:25AM
(#8330417)
The Cocoa/Objective-C links are for building apps, not higher-level automation.