AppleScript Fun with Claude

I occasionally use AppleScript to avoid repetitive tasks. I quite enjoy writing scripts. My scripting tend to follow the guess and check procedure. It can be weeks or months between these efforts so I need to look up the library or search for many basic things1.

In my part time job, I quite often report findings or issues with the Glow Blogs system. In doing so I need to remember to include: computer model, OS version Browser and Browser version. This is quite simple but requires a few clicks and a bit of typing. I thought today I might create and AppleScript to do this for me.

I then thought I might use Claude.ai to get me started2. I used the prompt:

Can you give me a n applescript that will report on the current model of mac, the version of the OS and the current application & version?

I’ve noticed that AI doesn’t seem to be bothered with my constant typos!

The first script threw an error when I tested it. So I copied the error and the line it came from and sent it back to Claude. Another error. This continued through 10 versions. Sometimes I broke off to test an idea of my own or check the AppleScript Library and reported that to Claude.

This began to feel a bit like my usual process of testing, checking and reading. But a good bit quicker. We finally got there. I just added a line to copy to the clipboard and put the script in the Script Library so I can call it with FastScripts 3.

For some reason I thanked Claude:

You’re welcome! The final script successfully gets:

1. The Mac’s hardware model

2. Current OS version

3. Active application name and version

Just for future reference – we went through several approaches before landing on the most reliable method using osascript to directly query the application’s version. This ended up being more robust than trying to get the version from file metadata or application paths.

Let me know if you need any modifications or have other AppleScript questions!

At this point I only had one free message left. So I asked Claude to refactor the script into a shell script. This it did with one error. With no more messages left, a search produced a fix pretty quickly. I ended up with this.

This is true of all the scripty type things I do. Except for HyperCard which I used every day for years. ↩︎

I’ve been using free versions of AI for a while now. A few times a week. Mostly for school things. Creating a text for pupils, or questions on a text. Claude is my current fav for scripting. ↩︎

I think FastScript is one of my favourite mac applications. It is very handy for this sort of script as you can either select it from FastScripts menu or give it a keyboard shortcut. The Front application, which we are interested in, stays at the front. ↩︎