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.
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.