r/applescript • • Feb 21 '26

Best ways to learn the very first basics of AppleScript?

12 Upvotes

I am completely new to AppleScript. I have a high-basic understanding of how to use apps on my MacBook Pro M4. I am trying to figure out what use cases I might have for automating drudge work and friction points in my day-to-day. What are the best idiot-proof places for me to go to try to learn the very basics of AppleScript, step-by-step, dumbed-down, jargon-free? I have attempted to use Oboe to set up such a learning experience with AppleScript for myself, but already I'm finding it is moving to fast and I keep having questions without a Q&A opportunity or an easy-to-use, easy-to-understand reference available. I'm grateful for multiple suggestions anyone might offer.


r/applescript • • Oct 28 '23

I made an app that combines AI and Mac automation, would love some feedback!

12 Upvotes

Hey everyone,

With recent developments in AI, I have been very interested in using it to make my Mac automation simpler, more intuitive, and more powerful. This is how I ended up creating ChatPC.

ChatPC allows you to use simple English to automate your Mac. It can manage files and interact with other Mac applications through Shortcuts and AppleScripts.

Check out this quick demo:

Safe by design - With ChatPC, you are in total control and your data is kept private.

  • By default, ChatPC cannot execute any actions on your Mac. You must explicitly give ChatPC access to the folders, Shortcuts, and AppleScripts that it can action on.

  • In addition, you can configure which actions require your explicit approval before executing.

  • Your data is your data. It is never used for training models and all communication between ChatPC and OpenAI are encrypted. See OpenAI’s Enterprise Privacy for more information.

I'm currently looking for beta testers to try out the app and give me feedback! The app is free to use up to some token limit. If you hit the limit, DM me with your initial thoughts and the email address you signed up with -- I'll be giving free coupons to the first 100 beta testers!

To get started, check out the MacOS Getting Started Guide (MacOS 13.0 or higher required).


r/applescript • • Apr 14 '22

pov: programmers have no idea to code

Post image
12 Upvotes

r/applescript • • Apr 19 '21

New AppleScript functionality in 2021 (Pages, Numbers, Keynote)

Thumbnail
9to5mac.com
12 Upvotes

r/applescript • • Dec 14 '20

Is there a centralized online library of AppleScript dictionaries?

12 Upvotes

I'm thinking something like the site that publishes linux manpages.

It would be helpful to know which versions of an app are scriptable, and if/how their commands changed between versions. I would also like to be able to search for commands in apps I don't have.

Normally I would just go to the Apple Store to check to see what's new but I haven't been out much with the pandemic. If anyone can just send me the latest dictionary for numbers that would satisfy my immediate need.

Thank you.


r/applescript • • Nov 20 '20

Clear all notifications with single script on Big Sur?

12 Upvotes

During my workflow I end up with a ton of notifications and in Big Sur it's a pain to close each one by either swiping away or clicking the tiny X.

Does anyone know how to batch clear notifications?

I saw this script, but it doesn't work in Big Sur, I get an error where it can't "get button 'Close' of window 1 of process 'NotificationCenter'":

tell application "System Events"

tell process "NotificationCenter"
    set numwins to (count windows)
    repeat with i from numwins to 1 by -1
        click button "Close" of window i
    end repeat
end tell

end tell


r/applescript • • Nov 12 '17

My script for Mail on macOS that automatically unsubscribes from promotional emails and newsletter

Thumbnail
github.com
12 Upvotes

r/applescript • • Sep 05 '26

How to script focus toggle for quick action

11 Upvotes

I'm trying to create a quick action to show up in the system wide services. So far I was able to find another solution which was to run a shortcut using AppleScript.

tell application "Shortcuts Events" to run the shortcut named "Set Focus"

This hypothetically works, but I was wondering if there was a more direct way to access this toggle using AppleScript. I'm trying to make a function key shortcut in order to toggle my personal focus mode as opposed to DND.

Any help is greatly appreciated!!


r/applescript • • Apr 07 '25

Using AI to generate applescript

11 Upvotes

Has anyone been able to generate fully functional applescript using any of the existing AI tools?

It seems people do not use applescript much and LLMs are not much trained as well


r/applescript • • Mar 14 '23

How to post AppleScript Code to /r/applescript

11 Upvotes

In order for your AppleScript code to be legible on Reddit you should switch the Post dialog to 'Markdown Mode' and then prefix every line of your code with four ( 4 ) spaces before pasting it in. Any line prefixed with four spaces will format as a code block. Interestingly, I find that I have to switch back to Fancy Pants Editor after completing the post for the formatting to apply.

Like this.

The following code will take code from Script Editor or Script Debugger's frontmost window and properly format it for you. It has options you can disable that filter your username from the code and inset the version of AppleScript and MacOS you are running. Iv'e pasted the results of running it on itself below.

--Running under AppleScript 2.8, MacOS 13.0.1
--quoteScriptForReddit.scpt--copperdomebodha--v.1.0.1
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
--Defaults to include environment and remove username.
set includeEnvironment to "Yes"
set usernameFiltering to "Yes"
tell application "System Events"
    set currentUserName to name of current user
    set frontmostApp to name of item 1 of (every application process whose frontmost is true)
end tell
set sysInfo to system info
set testEnvironment to "    --Running under AppleScript " & AppleScript version of sysInfo & ", MacOS " & system version of sysInfo & return
--Confirm action with user.
display dialog "This script will copy the contents of the frontmost window of " & frontmostApp & " and format it for Reddit's Posting dialog set to 'Markdown Mode'." buttons {"Options", "Cancel", "Ok"} default button "Ok"
set userApproval to button returned of result
if userApproval is "Options" then
    set includeEnvironment to button returned of (display dialog "Prefix code with ennvironment information?" & return & return & "Preview:" & return & testEnvironment buttons {"Cancel", "No", "Yes"} default button "Yes")
    set usernameFiltering to button returned of (display dialog "Remove your username form the code?" buttons {"Cancel", "No", "Yes"} default button "Yes")
end if
try
    using terms from application "Script Debugger"
        tell application frontmostApp
            tell document 1
                try
                    set codeText to (source text)
                on error
                    set codeText to (contents)
                end try
            end tell
        end tell
    end using terms from
    set codeText to my replaceStringInText(codeText, {return, "
"}, (return & "    ") as text)
    set codeText to (my replaceStringInText(codeText, tab, "    ") as text)
    if includeEnvironment is "Yes" then
        set codeText to (testEnvironment & "    " & codeText) as text
    end if
    if usernameFiltering is "Yes" then
        set codeText to my replaceStringInText(codeText, currentUserName, "UserNameGoesHere") --censor the users name if present in the code.
    end if
    set the clipboard to codeText
    set dialogText to "The code from the frontmost window of " & frontmostApp & " has been reddit-code-block prefixed and placed on your clipboard."
    if usernameFiltering is "Yes" then
        set dialogText to dialogText & return & return & " Any occurence of your username has been replaced with 'UserNameGoesHere'."
    end if
    activate
    display dialog dialogText & return & return & "Please remember to switch the Posting dialog to 'Markdown Mode'."
on error e number n
    display dialog "There was an error while Reddit-formating your code text." & return & return & e & " " & n
end try

on replaceStringInText(textBlock, originalValue, replacementValue)
    set storedDelimiters to AppleScript's text item delimiters
    set AppleScript's text item delimiters to originalValue
    set textBlock to text items of textBlock
    set AppleScript's text item delimiters to replacementValue
    set textBlock to textBlock as text
    set AppleScript's text item delimiters to storedDelimiters
    return textBlock
end replaceStringInText

It's easy to use this script from the script menu.

  1. Enable "Show Script menu in menu bar" from within Script Editor's Preferences.

  2. Create the path "Macintosh HD:Users:UserNameGoesHere:Library:Scripts:Applications:"

  3. Create a subfolder, for whichever AppleScript editor that you use, inside of the folder above. It will be named either "Script Editor" or "Script Debugger"

  4. Compile and Save the script above into the AppleScript editor folder you just created.

  5. Open an AppleScript that you would like to format for r/applescript..

  6. Select the script 'quoteScriptForReddit.scpt' ( or whatever you named it ) from the pull-down Script menu.

  7. Go to Reddit, open a new Post dialog, switch to 'Markdown Mode', Paste, Switch back to Fancy Pants editor and your formatting will preview.

  8. Post!

Reddit does have a <c> ( code block ) format switch in the fancy pants editor which retains some key word bolding and works reasonably. It does not, however, retain indentations of code blocks from your editor.


r/applescript • • Mar 26 '20

I made/collected JXA code examples for quick reference and learning

Thumbnail
github.com
11 Upvotes

r/applescript • • Dec 22 '22

Scripting for Dummies

10 Upvotes

Hello smart people of the world, dummy here!

I have a problem: I do not know where to find well organized, jargon-free documentation for someone fairly new to the OS X world. I've spent too many hours digging around on the internet hoping someone will have a well made tutorial or guide on how to automate basic processes on a MacBook.

For deeper context, I work for a school who's solution to user data removal on loaner devices has always been:

  1. Log into the local admin account with a twelve character passcode.

  2. Navigate to "Users & Groups" in system preferences.

  3. Select the loaner user account and delete the home folder.

  4. Make a new loaner user account and fill in their name and password.

  5. Log out of the local admin account.

  6. Log into the new loaner user account and complete the first time setup menus.

Edit: All accounts are local. We plan on using active directory in the distant future, but as of now we do not have the human resources for implementation. The name of the local user accounts can be anything, although some consistency is nice.

This tedious process takes about 3 to 5 minutes a piece and needs to be done 10 to 20 times a day. We have Mosyle as our MDM, and theoretically it could be done there but the support team I've been talking to is usually inept. Using the guest account is out of the picture unfortunately as a student could have a laptop for more than a day, and I would like it to save their data.

Anyone know of any resources that might help me learn about this stuff? Maybe you have a better solution than a script on a flash drive? If you do, you're awesome. Thanks!

(Before I get slammed: yes, I'm underqualified. Please be respectful.)


r/applescript • • Dec 19 '22

Script to reverse the scroll direction.

10 Upvotes

Hi,

Didn't know where to post this. I've been having trouble creating an applescript to reverse the scroll direction on Ventura. I finally figured it out and am posting so others could use it.

The old script before Ventura was:

try
tell application "System Settings"
	reveal pane "com.apple.preference.trackpad"
end tell
tell application "System Events"
	tell process "System Preferences"
		click radio button "Scroll & Zoom" of tab group 1 of window "Trackpad"
		click checkbox 1 of tab group 1 of window "Trackpad"
		tell application "System Settings" to quit
	end tell
end tell
end try

The working version for Ventura is this:

# This should work with Ventura 13.1 (2022-12-19)

do shell script "open x-apple.systempreferences:com.apple.Trackpad-Settings.extension" -- Opens the trackpad settings window
delay 0.7 -- The delay is there to make sure the System Events can click buttons.
tell application "System Events"
    tell process "System Settings"
	    click radio button 2 of tab group 1 of group 1 of group 2 of splitter group 1 of group 1 of window 1
	    click checkbox "Natural scrolling" of group 1 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window 1
	    tell application "System Settings" to quit
    end tell
end tell

If anybody finds a better way, please let me know!


r/applescript • • Nov 30 '22

[Request] Script Editor keeps losing permission to send keystrokes [Error: 1002]

10 Upvotes

I have written a number of scripts to help automate workflow in my office.
The basic premise is to highlight information on excel online, do some math and rearranging within applescript, put some information back in excel, and put information in a text message.
This is initiated by using Automator to run the scripts from a keystroke (F14-F19).

The current issue is that throughout the day, we will get errors that [written program name] is “unable to send keystrokes” [Error 1002].

The issue has progressed to become worse, and so has the solution.

For OS x 13:

  • The solution is to trick the computer into letting it work.

  • First, remove “Script Editor” from Privacy & Security -> Accessibility, then re-add “Script Editor”.

  • Next, run any script that is NOT the initial one to cause the error.

  • Now it should be fixed.

For OS x 12 and earlier:

  • Remove the program in question from Privacy & Security -> Accessibility, re-add program, and it should work as desired.

Also worth noting that once one script is not allowed to send keystrokes, none of them will be allowed to send keystrokes until the above mentioned solution is implemented.

——

In days bygone, I could edit scripts and all would be well.
Eventually, it became where if i would edit scripts, i would have to immediately remove the scripts permissions from accessibility, then re-add them.
Now, as of OS x 13, they will randomly lose permissions, which is making it almost unusable.

I have tried exporting the script to a signed application, I have tried saving programs as applications and as scripts. None of these solutions work.

I have contacted Apple about this concern, but they have advised me that it is outside their scope of assistance, so I am hoping greatly that anyone here can help me.

I can send the scripts in here if that will make a difference.

——

The 3 machines that are present and experiencing this issue are:
2020 Mac Mini M1 - 13.0.1
2020 MacBook Air M1 - 11.6.5
2020 Macbook Air Intel - 11.6.8

There are more machines having this issue, and every machine that we have has this issue, but there’s are the 3 before me that i have testing ability with.


r/applescript • • Oct 12 '22

Using `on open location` in JXA

Post image
10 Upvotes

r/applescript • • Jan 07 '26

Can someone explain the scripting additions to me?

9 Upvotes

Almost every sample script I see has a line at the top that explicitly includes them.

What are "they"? Because I have NEVER included them in any of my scripts. And I've never had any features of applescript be unavailable to me.

And I often see a line declaring a specific version of applescript. Whats THAT about? I've also never done that in 30+ years of occasional scripting, Yet I see it all the time.

It all makes me think either I'm missing something big, or literally nobody knows what they're doing?


r/applescript • • Nov 05 '25

Any AppleScript issues in Tahoe 26.1?

9 Upvotes

Presently remaining on Sequoia 15.7.2. Tahoe seems like a hot mess.


r/applescript • • Oct 08 '24

made a thing. file sorter. first script!

9 Upvotes

r/applescript • • Nov 02 '22

What can AppleScript do?

9 Upvotes

Hey! I’ve been curious about AppleScript for a while now, I know it’s supposed to automate tasks in macOS but I’d like to know what are its limits? what’s the most complex thing you can program with it? or some examples of useful automations with AppleScript

Thank you


r/applescript • • Feb 09 '22

Simple script for opening 1 and only 1 tab under a specific profile for Google Chrome

9 Upvotes

Quick and useful:

activate application "Google Chrome"
tell application "System Events"
	tell process "Google Chrome"
		click menu item "<Name of the profile>" of menu 1 of menu bar item "Profiles" of menu bar 1
	end tell
    delay 1
    tell front window of application "Google Chrome"
        make new tab
        if active tab index > 1 then
            close (tabs 1 thru (active tab index - 1))
        end if
    end tell
end tell

r/applescript • • Sep 01 '21

MY SINGLE WORST ENEMY

9 Upvotes
Expected end of line, etc. but found end of script.

r/applescript • • Nov 01 '20

Things AppleScript Should Have

9 Upvotes

AppleScript was first programming language to be honest. Over the years, I've had these tiny annoyances with AppleScript and I just wanted to share them with everyone (if someone's a developer at Apple who is involved in the development of AppleScript, I suggest you take a look at these things).

  • Adjustable origin positioning for dialog boxes

    • When you run display dialog, display alert, or any type of dialog box, the position is always centered on screen. If I move the window elsewhere, and run the code again, it re-centers. This isn't a huge issue, but it would add to it's consistency with the aesthetic of macOS.

  • (Real) Dark mode for Script Editor

    • This is one is the most critical problems, being that the background in Script Editor isn't actually dark when dark mode is enabled. It stands out as white and can be compared to Discord light theme.

  • Option to switch to legacy layout for alerts

    • As of this post, I'm running macOS 11.0.1 Big Sur Beta. It significantly changes the overall aesthetic to a more rounded, translucent, and neumorphic look. Apart of this change is the style of alert boxes. I've uploaded a picture of the new style compared to the old one at the bottom of the post. Anyways, there should be an option to display an alert using the legacy (pre-Big Sur) style, as some of my script projects look inconsistent with it. The square alert boxes and the rectangular dialog boxes don't go together very well.

  • Configurable buttons for lists

    • When you run the code choose from list {"Option 1", "Option 2", "Option 3"}, it presents the specified items in a list. On the box, there are an additional two buttons which are labeled "Cancel" and "OK". It'd be great to customize these buttons by specifying them in the code, such as: choose from list {"Option 1", "Option 2", "Option 3"} buttons {"Quit", "Continue"} default button 2.

  • More mathematical operators

    • I personally don't use a ton of mathematical operators in my scripts like mod, but I know it would help in a lot of places for others.

  • AppleScript shell identical to that of Terminal

    • This is also one of the biggest challenges I face when writing scripts. I once wrote a password manager that encrypts your passwords using Terminal's built-in OpenSSL codec, and decrypts them using password you set. That script by far had the most challenging problems like authenticating an encryption through AppleScript and whatnot. I tried encrypting the file using do shell script with the same command, but it would never work. It'd be life-saving if the AppleScript shell was identical to Terminal so you wouldn't have to tell Terminal to do a command from the script.

  • More input types

    • Last but certainly not least, more input types. The only inputs I know of are display dialog, display alert, choose from list, and display dialog with default answer "". Basically, buttons and text are the only things you can interact with. Adding more input types would add so much more flexibility to AppleScript. Some additional input types could be:

      • Incrementors (like in setting the time on a mac)

      • Sliders (like in setting brightness)

      • Check boxes (multiple choice options)

      • Option boxes (single choice options)

      • Switches

These are only a few of several things that could be improved in AppleScript. It'd be awesome if Apple released version 2.8. Does anyone else have something they want fixed too?


r/applescript • • Jan 15 '19

Is anyone seriously using AppleScript?

9 Upvotes

I'm playing around with AppleScript and writing a set of Perl modules to make it easier to write scripts. I'm noticing quite a few bugs (at least with Finder). For example, the code generated to hide a column by AppleScript's record feature doesn't work at all. I had to resort to some obscure, undocumented feature to hide a column in Finder.

As I google around, I'm not seeing a lot of activity with AppleScript these days. Are there developers who use it as a serious tool instead of just for one-off scripts for very simple, basic automation? Based on the hoops I've had to jump through so far, it doesn't feel like a very robust scripting language.

Thanks.


r/applescript • • Mar 01 '25

What are your personal Top 3 favorite, quick AppleScript hacks that Apple Shortcuts still can't do?

8 Upvotes

Apple Shortcuts is pretty awesome but only when combining it with AppleScript are your true customization capabilities unlocked!

What are your personal Top 3 favorite, quick AppleScript hacks that Apple Shortcuts still can't do on its own?


r/applescript • • Feb 21 '24

Suicide script? (Doesn't work)

Post image
8 Upvotes