Applescript
This repository is a collection of Applescript snippets that can be used individually or part of a larger project. Many of these snippets were written as I was learning to use Applescript and may not represent the best method of undertaking a particular task. Feel free to open an issue or pull request if you find that any of these files do not work for you. You may also open a pull request if you would like to add a script or snippet.
Copies of this repository exist at Github and Gitlab.
Script Categories
- Application Services
- Display Settings
- File and Folder Actions
- Location Helper Scripts
- Markdown Tools
- Notational Velocity
- Pandoc and Textutils
- Reminders App
- Snippets
- Sound Scripts
- Temperature Conversion
- Terminal
- Time and Date
Links/Dependencies
- Caffeine App - a menu bar application that prevents your monitor from sleeping. There are also several other applications that achieve the same goal.
- If you don't want an extra application in your menubar you can use
pmset noidle
- this command must be run as
do shell script "/usr/bin/pmset noidle > /dev/null 2>&1 &"
to prevent the script from waiting for the shell command to complete.
- this command must be run as
- Or if you're on 10.8+ you can use the built-in
caffeinate
command, though it may be broken after Yosemite (10.10). caffeinate
andpmset noidle
can be run via thedo shell script
Applescript command.
- If you don't want an extra application in your menubar you can use
- Pandoc and Textutil - document conversion via the command line.
Youtube-Post.scpt
requires GoogleCL, which is also useful for blogger, google calendar, and contacts- GoogleCL is sadly defunct. Any associated scripts remain for posterity.
- I have also created a few Gists for more specific applescript/bash related tasks.
Other Applescript Resources/Libraries
Tools for Developing Scripts
Free
- Location Helper - use core location in applescripts.
- Twitter Scripter - interact with Twitter via applescript.
- Platypus - package applescripts with various other scripts (Shell, Python, etc) to create native MacOS applications.
Paid
- CursorCoordinates - get x,y coordinates for clicking and window positions.
- Dialog Maker - tool to help create dialog boxes
- Script Debugger - An integrated development environment for Applescript
A non-exhaustive list of interesting Applescript resources on Github:
Note Taking/Task Management
Coding
- iTerm and Sublime Text
- Custom Iterm Applescripts for Alfred
- Execute Applescript with Node.js
- Execute Applescript with Go
Productivity
Other useful Applescript resources / tutorials / etc
- Basics of Applescript
- Free ebook covering the foundations of applescript scripting. Published in 2014.
- Introduction to AppleScript Language Guide
- MacOSX Automation/Applescript
- written by Sal Soghoian, the former Apple product manager for automation technologies
- MacScripter Forums
- MacRumors/Mac Programming Forum
- not explicitly applescript related, but searching for "Applescript" provides some useful results
- A thorough explanation of "do shell script" in Applescript
For JavaScript Users
- JavaScript for Automation Cookbook
- JavaScript was added as a MacOS automation tool in version 10.10. If you are familiar with (or would prefer to learn) JavaScript, this cookbook is a great resource.
Bugs / Contributing
Scripts in this repo were tested on OS X/MacOS Lion through High Sierra. Please open an issue or pull request if a script does not work as intended.
If you have a script, snippet, or resource that you'd like me to include in this repo, feel free to open a new pull request.
To Do
To be completed as I have time
- Actually update this repo
- Reorganize and rename variables, folder structure, docs, readme
- (Maybe) Build tests (via python nsapplescript)