2

I've recently discovered AppleScript. AppleScript affords a simple, natural way to programmatically simulate keyboard-and-mouse interaction with Mac applications. AppleScript is great, however it suffers from the following problems:

  1. The latest stable release is from 2014, and last year the AppleScript product manager was laid off and his position was eliminated.

  2. The official documentation has not been updated since January 2016, and all of the tutorial and reference books that are dedicated to AppleScript date no later than 2010 (with the exception of this one, which seems to be a copy-and-paste of some stackexchange Q&A with the AppleScript tag).

  3. Script Editor, the built-in AppleScript development environment, has no debugging capabilities. There seems to be just one commercial IDE for AppleScript*. It looks amazing and has all the debugging features that one would expect from a modern IDE, but it costs $100, which would be too expensive for my pocket even if Apple did not seem to be phasing out this programming language (see bullet point #1).

Are there any alternatives to AppleScript? Is there an actively developed and supported programming language with a good, cheap IDE, and good, up-to-date documentation, that makes it possible to simulate keyboard-and-mouse interaction with Mac applications in a quick and easy way? Something, maybe, like the Apple counterpart for Microsoft's VBA (Visual Basic for Applications) for their Office suite on Windows?


* It appears there's another third-party AppleScript IDE: Smile. Unlike Script Editor, Smile is free of charge.

  • 2
    AppleScript is the counterpart of VBA :-) What kind of problems do you intend to solve with AppleScript or whatever alternative people might propose? There are some tools available but the specific one heavily depends on your intentions. – nohillside Apr 18 '17 at 8:36
  • 1
    @patrix: Take this for instance. I've recently had the need to perform the following on a list of 8000 corrupt PNG image files: 1. Open the file in Preview, 2. Save it back. This simple procedure was enough to correct the files' corrupt META info. Using AppleScript I was able to do this very easily. – Evan Aad Apr 18 '17 at 8:42
  • 1
    Reports of AppleScript's demise may be premature. Its design dates from Mac OS 7.1 IIRC and it is interdependent with Mac application IPC. Shell scripts can run snippets of AppleScript using the osascript command. By extension C, C++ and Objective-C have the same capability. However, that would be cumbersome compared to (I believe) AppleScript APIs available to all those languages. And I haven't even considered at Swift yet. From O'Reilly "Applescript and Python are quite different, but can be used together to make very efficient tools without compromising the modularity of Python". – D A Vincent Apr 18 '17 at 11:12
  • 1
    Sorry. I meant I myself haven't taken the time to find out what the plan is with Swift. My money would be on a convenient API soon, if not already. And if Apple don't do it, nothing would stop someone else doing it. – D A Vincent Apr 18 '17 at 12:27
  • 1
    If you want an IDE for AppleScript, look at ScriptDebugger from Late Night Software (latenightsw.com). It has debugging and breakpoints etc, and is FAR more capable than Apple's ScriptEditor. It is commercial, but well worth if if you are a serious scripter. You can also use many of Objective-C's methods in AppleScript, which gives you a LOT of additional built in methods to use, but does add complexity to your script. Also check out macosautomation.com for other tips. – Chris Paveglio Apr 18 '17 at 19:31
4

First of all: DON'T PANIC :)

No, there are no good/useful/less painful alternatives to Automator/AppleScript. At least not if you really need to automate some workflow within the UI.

  • 4
    I'm hoping with the acquisition of Workflow for iOS, Apple is aiming to cleanup and unify automation of macOS and iOS. One can dream, eh? – Melwan Apr 18 '17 at 10:50
  • Workflow/Shortcuts is significantly less powerful than Applescript. A much closer cousin would be Automator. – Wowfunhappy Mar 9 at 0:37
9

Since Yosemite, OS X/macOS also supports JavaScript as an inter-process scripting language--officially known as JavaScript for Automation, also referred to as JXA. The documentation (and some would say, the implementation) is somewhat lacking compared to AppleScript, but if you're already more familiar with JavaScript than AppleScript, then it might be an option.

Like AppleScript, JXA also offers an ObjC bridge allowing you to use Cocoa APIs in your JavaScript.

One advantage is that there are many more editors and IDEs out there designed for JavaScript coding than there are for AppleScript, though Script Editor and Automator probably still have the edge for debugging JXA-specific stuff.

Official resources:

Some unofficial resources:

  • This seems like the most correct answer – David Mar 18 at 20:25
0

Script Debugger, which you mention, is free for most uses, with a $99.99 USD fee, (1-2 users), only for certain advanced features.

I wouldn't be too worried by the lack of development: the language is very stable, and apps (including those by Apple) continue to have support for AppleScript.

For instance, Preview's AppleScript capabilities have improved since 2014.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .