For the six years I’ve been using a Mac, I’ve often wanted to learn how to use AppleScript to automate processes I repeat. Today I finally did.
As part of my routine for keeping my Mac running efficiently, I like to re-boot it every couple of days. And to make sure it continues to boot quickly, I’ve made sure I’ve deleted everything that wants to auto-startup at boot. That way, I get a nice, clean, quick boot if I need it.
However, there are also a number of sites and apps that I use all day that I need to run. So instead of opening them all up individually after a new boot, I’ve written an AppleScript to do it for me.
Now if you’re an old AppleScript hand, this is probably stupidly simple. But I know lots of friends and family who have moved to a Mac in recent years and who aren’t programmers, so this is for them.
The Steps.
1. Open AppleScript. It comes pre-installed on your Mac. Find it by searching Spotlight.
2. Start a new script.
3. Cut & Paste my code from below. Change the URLs you want to open and the App you want to run according to your tastes.
4. Click “Compile” on the AppleScript toolbar.
5. Flie > Save. Save it to your Applications folder. Make sure the “File Format” is “Application”. Call it whatever you want – mine is just called ‘Startup’.
6. Lastly, open up the Applications folder and drage the icon for the new app to your dock. Close AppleScript.
Now, when you boot, after the dock loads, just run the new app and it will open all of your sites and apps for you.
open location “http://gmail.com”
open location “http://facebook.com”
tell application “TextExpander”
activate
end tell
tell application “Alfred 2”
activate
end tell
tell application “CrashPlan”
activate
end tell
tell application “PopClip”
activate
end tell
tell application “Bartender”
activate
end tell
tell application “Fantastical”
activate
end tell
tell application “Moom”
activate
end tell
tell application “Skype”
activate
end tell
tell application “TweetDeck”
activate
end tell
tell application “Evernote”
activate
end tell
tell application “Spotify”
activate
end tell
You can shorten this script and make it easier to maintain by using a couple loops. You simply need to edit the list of sites and applications to add/remove them from your startup.
property TheSiteList : {“http://gmail.com”, “http://facebook.com”}
property TheAppList : {“Evernote”, “TextWrangler”}
repeat with TheSite in TheSiteList
open location TheSite
end repeat
repeat with TheApp in TheAppList
tell application TheApp to activate
end repeat
Chris
I am looking for something like this also, but will also open the app windows to the correct boundaries that I like on multiple monitors.
Looking for something like this also. Were you ever able to find one?
Not looking to necropost, but in case you haven’t discovered it yet, wanted to tell you that this could be achieved slight shorter-handed:
tell application “TextExpander” to activate
tell application “Alfred 2” to activate
tell application “CrashPlan” to activate
tell application “PopClip” to activate
tell application “Bartender” to activate
tell application “Fantastical 2” to activate
tell application “Moom” to activate
tell application “Skype” to activate
tell application “TweetDeck” to activate
…would totally do the trick. Because you’re one-lining the commands you don’t need line breaks and “end tell’s”. Makes it easier to read and maintain, IMHO.
FYI. ¯\_(ツ)_/¯
Thanks. These days I’m doing this kind of thing via Alfred instead.