Seeking Alternative to AppleScript for Automation Tasks

Hi everyone,

I’ve been using AppleScript for automating a few of my tasks, but I’ve realized that AppleScript tends to be quite UI-specific and may not be the most flexible option for long-term automation.

I originally wrote my AppleScript during macOS Bigsur, it was working fine till Ventura and not properly working on other versions, I’d prefer not to rely on AppleScript for the future and am exploring alternative languages for automation that offer more stability, flexibility, and compatibility across macOS versions.

Does anyone have recommendations for a language or framework that can help achieve the same functionality I’ve been getting with AppleScript? Ideally, I’m looking for something robust and adaptable for macOS automation tasks.


Thank you for your suggestions!

Posted on Jun 16, 2025 2:13 AM

Reply
Question marked as Top-ranking reply

Posted on Jun 16, 2025 5:52 AM

Some Apple and third-party applications are written with AppleScript scripting dictionaries incorporated within the App bundle for the purpose of controlling that application with certain AppleScript reserved words. Some of these dictionaries are robust (e.g. MS Word) and some limited (e.g. Apple's Preview). If you open a blank Script Editor document and subsequently use the File menu > Open Dictionary… you will see a list of those applications.


If you have done any AppleScript-based GUI scripting, that is very fragile to future application interface design changes which Apple is constantly revisiting. Caveat emptor.


Apple introduced JavaScript for Automation (JXA) that is also supported in the Script Editor. Apart from specific application scripting dictionary support for JXA, there is limited documentation available for it from Apple, and one learns by web searching for what others have done. Unlike AppleScript, JXA supports the full scripting bridge so you can use Classes from CoreGraphics, CoreFoundation, and other Frameworks directly.


Apple is doing very little to improve AppleScript or JXA support and I would not depend upon scripts these languages for long-term Apple automation support. Apple is moving away from Automator to its Shortcuts solution.


Apple's Foundation Framework includes the NSAppleScript Class. One can use that to run AppleScript from Objective-C, Swift, or even Python 3 (with current PyPy pyobjc package).


Here is Swift 6 getting the current (this post) tab URL from Safari 18.5 in Sequoia v15.5:

#!/usr/bin/swift

import Foundation

var error: NSDictionary?
let browserTab = "tell application \"Safari\" to get URL of current tab of window 1"
let scriptObject = NSAppleScript(source: browserTab)!
let outURL: NSAppleEventDescriptor = scriptObject.executeAndReturnError(&error)
guard error == nil else {
    fatalError("AppleScript flaw or Safari not running.")
}
print(outURL.stringValue!)


chmod +x ./test.swift
./test.swift
https://discussions.apple.com/thread/256081580?sortBy=oldest_first



8 replies
Question marked as Top-ranking reply

Jun 16, 2025 5:52 AM in response to shivam5435

Some Apple and third-party applications are written with AppleScript scripting dictionaries incorporated within the App bundle for the purpose of controlling that application with certain AppleScript reserved words. Some of these dictionaries are robust (e.g. MS Word) and some limited (e.g. Apple's Preview). If you open a blank Script Editor document and subsequently use the File menu > Open Dictionary… you will see a list of those applications.


If you have done any AppleScript-based GUI scripting, that is very fragile to future application interface design changes which Apple is constantly revisiting. Caveat emptor.


Apple introduced JavaScript for Automation (JXA) that is also supported in the Script Editor. Apart from specific application scripting dictionary support for JXA, there is limited documentation available for it from Apple, and one learns by web searching for what others have done. Unlike AppleScript, JXA supports the full scripting bridge so you can use Classes from CoreGraphics, CoreFoundation, and other Frameworks directly.


Apple is doing very little to improve AppleScript or JXA support and I would not depend upon scripts these languages for long-term Apple automation support. Apple is moving away from Automator to its Shortcuts solution.


Apple's Foundation Framework includes the NSAppleScript Class. One can use that to run AppleScript from Objective-C, Swift, or even Python 3 (with current PyPy pyobjc package).


Here is Swift 6 getting the current (this post) tab URL from Safari 18.5 in Sequoia v15.5:

#!/usr/bin/swift

import Foundation

var error: NSDictionary?
let browserTab = "tell application \"Safari\" to get URL of current tab of window 1"
let scriptObject = NSAppleScript(source: browserTab)!
let outURL: NSAppleEventDescriptor = scriptObject.executeAndReturnError(&error)
guard error == nil else {
    fatalError("AppleScript flaw or Safari not running.")
}
print(outURL.stringValue!)


chmod +x ./test.swift
./test.swift
https://discussions.apple.com/thread/256081580?sortBy=oldest_first



Jun 16, 2025 6:48 AM in response to shivam5435

shivam5435 wrote:

Does anyone have recommendations for a language or framework that can help achieve the same functionality I’ve been getting with AppleScript? Ideally, I’m looking for something robust and adaptable for macOS automation tasks.

The truth is that macOS has very poor support for automation. Sometimes you can use command-line operations, but not all features have a command-line option. Sometimes you can use Apple Script, but the results you describe are typical.


Javascript for Automation is simply Javascript bolted on top of the same technology used by AppleScript. It was abandoned a decade ago. In fact, it was abandoned almost immediately upon release. 😄


"The Future" is now Shortcuts. In most cases, they don't do very much. But sometimes, they can be oddly very powerful. They do seem to avoid most of the problems with AppleScript. Shortcuts would be the recommended option. However, they do suffer from the same limitations as AppleScript. They do what they do and that's it. They aren't extendable in any way.


Automator is still an option. It's really the only practical way to "extend" AppleScript by connecting multiple apps, with potentially command-line operations. Technically AppleScript already supports this, but AppleScripts are always very fragile. Automator seems to construct them more robustly, that's all.

Jun 16, 2025 7:32 AM in response to shivam5435

shivam5435 wrote:

@Barney-15E
for example : I am using applescripts to automate downloading of any tool like whatsapp, telegram , slack etc..
all have different UIs right ? (during the download procedure) so for some softwares it works fine but for some it stuck at some point in different versions.
this is one of the use case, there are many that's why I want to find any alternative .

Do you mean UI scripting? That is and always will be perilous as it depends on knowing the enumeration of interface elements. That enumeration could change randomly when the app is recompiled.

I can’t imagine any solution that would be robust.


Jun 16, 2025 6:54 AM in response to Barney-15E

@Barney-15E

for example : I am using applescripts to automate downloading of any tool like whatsapp, telegram , slack etc..

all have different UIs right ? (during the download procedure) so for some softwares it works fine but for some it stuck at some point in different versions.

this is one of the use case, there are many that's why I want to find any alternative .

Jun 16, 2025 9:17 AM in response to shivam5435

shivam5435 wrote:

for example : I am using applescripts to automate downloading of any tool like whatsapp, telegram , slack etc..
all have different UIs right ? (during the download procedure) so for some softwares it works fine but for some it stuck at some point in different versions.

Are you talking about content in those apps, or the apps themselves? Clearly you aren't talking about downloading, as that has nothing to do with AppleScript. They may have different installation procedures.


As is true in about 100% of cases, maybe you should take a step back and explain what you are trying to accomplish, at a high level. Because usually people don't ask for help until they are deep inside some rabbit hole. And all they ever ask for is a more efficient shovel and all we have are ladders and ropes.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Seeking Alternative to AppleScript for Automation Tasks

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.