AppleScript

Latest

  • AppleScript: download YouTube videos

    by 
    Cory Bohon
    Cory Bohon
    05.12.2008

    Keeping with the "self-built apps," I'm going to show you how to build your own YouTube downloader. Sure you could use applications like TubeSock, but where's the fun in that? This application will download the YouTube flash video from a pasted link, and all with a little AppleScript. Continue reading to learn how to build the YouTube downloader.

  • SSHing via Apple Remote Desktop with AppleScript

    by 
    Cory Bohon
    Cory Bohon
    05.07.2008

    Scott posted yesterday on a new series about SSH coming to Apple Matters. If you want to skip the learning and go straight to the Secure Shell-ing, then why not take a look at this recent post by John Welch. In this post, he describes how to set up a simple AppleScript that uses Apple Remote Desktop to SSH into a set of Macs on your local network. The script takes the machines you have selected in ARD (or, if you've only got one selected, just that machine) then opens SSH sessions in Terminal, ready for you to type your UNIX commands to your networked computers. If you want to get the script and start batch-connecting to your machines, visit his website.

  • AppleScript: Delete old folders

    by 
    Cory Bohon
    Cory Bohon
    05.05.2008

    If you work like I do, then you have a hierarchy of folders contained in a single folder that allows you to manage project files, notes, etc. Well, when it comes time to chunk those old files, normally you have to manually go through and remove them; this task can become daunting if you have multiple project folders. I am going to show you an easier way. In this how-to, we'll cover how to create an AppleScript that will allow you to remove folders that are older than 30 days. Continue reading to learn how to create this AppleScript.

  • AppleScript: Print daily iCal agenda

    by 
    Cory Bohon
    Cory Bohon
    04.28.2008

    var digg_url = 'http://digg.com/apple/TUAW_Use_an_AppleScript_to_have_iCal_deliver_a_daily_agenda'; If you use iCal to store you important dates and events, and use it on a regular basis without syncing events via an iPod, iPhone, or other device, then you know how frustrating it can be when you forget about an appointment or event. I'm going to show you a way to automatically print your daily iCal agenda with a simple AppleScript. You can set this script to run when your Mac starts up so you never miss an appointment!Continue reading to learn how to create this AppleScript.

  • Mac Automation: create a Mail-triggered "spy cam"

    by 
    Cory Bohon
    Cory Bohon
    04.22.2008

    Have you ever been away from your Mac, then come back only to find that your co-worker has stolen your favorite Apple pen? Well, I am going to show you how to catch them in the act by creating a Mac "spy cam." For this how-to, you will need to create an Automator workflow, AppleScript, and some Mail rules. So, cue the James Bond music, and let's begin. You do need an iSight or a newer Mac with a built-in camera. (Yes, I know there are some tools prebuilt to do this -- but what's the fun in that?)Continue reading to learn how to create the Mac spy cam.

  • Mac 101: schedule your scripts

    by 
    Brett Terpstra
    Brett Terpstra
    04.14.2008

    We talk about iCal once in a while. Did you know that an iCal alarm can launch an AppleScript? A recent comment from reader Zach (and subsequent replies) made us think that this tip might be of use to anyone who hasn't considered the possibilities. When you schedule an alarm in iCal, one of the options for the alarm is "Run script." If you select "Other..." from the script selection dropdown, you can choose any AppleScript you want to launch. Then you just tell the alarm when to go off and your script will run. Considering that AppleScript can control quite a few of the applications on your mac, and that iCal can handle repeating events, the possibilities are wide open. You could do something as simple as schedule applications by putting the following into a script in Script Editor and saving it as a regular script: tell application "Safari" to activate and another one... tell application "Safari" to quit to quit. Of course, you could then add to the scripts to have Safari navigate to certain pages as well. And you could launch as many apps as you want in the same script. Anything you can do with AppleScript, you can schedule. For more Terminal-savvy readers, Applescript's "do shell script" command allows for an even wider range of possibilities. You can even get user interaction with a "display dialog" command. I'm sure there's someone here who could have a blast with this.

  • Speedy creation of rich text links to Mail messages

    by 
    Brett Terpstra
    Brett Terpstra
    04.14.2008

    If you use any applications with Cocoa-based text editors (TextEdit, Mail.app, and many more), you may have noticed that some of them, like Mail.app, recognize URLs and automatically turn them into links. The links are in Rich Text Format (RTF) and can be copied and pasted into other RTF-compatible text fields. To the best of my knowledge, though, there's no easy way to automate the creation of an RTF hyperlink, via AppleScript or other means. In programs that don't detect URLs, or if you want to link text to a URL, you generally have to select text, go to a menu item (Link..., Link Add..., etc.) that's a few submenus down, and then enter the url. Me? I'm always looking for the easy way out...

  • AppleScript: Control iTunes with an e-mail

    by 
    Cory Bohon
    Cory Bohon
    04.13.2008

    var digg_url = 'http://digg.com/apple/Control_iTunes_with_AppleScript_using_e_mail'; Last week I talked about controlling your Mac with an e-mail; this week, as promised, I am going to show you how to apply this same idea to iTunes. So, without further ado, let's get started with writing some AppleScripts. Continue reading to learn how to control iTunes.

  • AppleScript: Control your Mac with an e-mail

    by 
    Cory Bohon
    Cory Bohon
    04.07.2008

    var digg_url = 'http://digg.com/apple/Control_your_Mac_with_an_e_mail'; Have you ever been away from your Mac and wanted to shut down, restart, or needed to open an application remotely, but didn't have access to anything except your iPhone? Well, I am going to show you how to do these tasks with AppleScript and Mail. This process is fairly easy and involves creating a simple AppleScript and some Mail rules. Note that since these rules will cause your Mac to perform the listed action when they run, be careful when testing!Continue reading to learn how to build this AppleScript.

  • AppleScript: backup iCal calendars

    by 
    Cory Bohon
    Cory Bohon
    03.30.2008

    iCal is great for storing your calendars and appointments, but what if you want to export (or backup) your calendars in case of a data emergency? Well, you could backup your calendars manually; however, AppleScript is so much cooler. Let's automate the backup of iCal calendars through the use of an AppleScript. Continue reading to learn how.

  • MacTech re-releases VBA to AppleScript Transition Guide

    by 
    Dave Caolo
    Dave Caolo
    03.28.2008

    As someone who spent months hand-crafting Visual Basic scripts in Microsoft Office, only to have Microsoft pull the rug out from under me with the release of Office 2008 (they abandoned VB support for the Mac. Grrr.), I'm very grateful to MacTech magazine and longtime AppleScript guru Paul Berkowitz.MacTech has re-released Paul's 150-page guide for making the transition from VBA to AppleScript (originally printed in the April 2007 issue of the magazine, and also available in modified form on the Microsoft Mac BU site). It's highly detailed, with step-by-step instructions. It looks like I know what I'll be reading next week (and if I run into trouble I can always bug Cory for help).You can download the guide as a PDF for $9.95US, or get the PDF plus a hardcover version for $19.95US. Both options include a free subscription to MacTech magazine, which is a great bonus for anyone who likes to dig into the underside of Mac OS X. If your wallet is a bit light, you can read the entire thing online for free.

  • AppleScript language guide updated, finally!

    by 
    Cory Bohon
    Cory Bohon
    03.12.2008

    Many people have criticized Apple for not updating their AppleScript language documentation regularly (myself included). Scoff no more, because Apple updated their documentation yesterday. The last update to the AppleScript language documentation was on May 5, 1999 -- almost 9 years ago. For anyone who thought that Apple was abandoning AppleScript for other ways of automation (such as Automator), fear not. This shows that Apple is still committed to bringing custom automation/scripting to Mac OS X and the 21st Century.

  • AppleScript: build a simple task launcher

    by 
    Cory Bohon
    Cory Bohon
    02.02.2008

    If you're like me, when you sit down at your Mac, you end up opening a few specific apps depending on what kind of project you're working on. I am going to show you how you can group these applications into "task launchers" that will bring up a suite of programs with one click. For instance, I have a script that will open iPhoto, iDVD, and iMovie called "Create Movies." When I run this script, it will open all of the applications I need to make my movie. I also have one called "Productivity" that will, when opened, launch Mail, iChat, Pages, and Yojimbo (even though some might argue with iChat's productivity value). Want to make your own launchers? Continue reading for the instructions.

  • AppleScript: saving scripts

    by 
    Cory Bohon
    Cory Bohon
    01.13.2008

    Just as there are multiple ways to save Automator workflows, there are also multiple ways to save AppleScripts. In this how-to, I will show you ways in which you can save your AppleScripts for future use.Read on for all the details.

  • Usable Keychain Scripting updated for Leopard

    by 
    Mike Schramm
    Mike Schramm
    01.08.2008

    Daniel Jalkut put together a little app called "Usable Keychain Scripting" a little while ago that was designed (what else?) to make scripting the Keychain a little more usable -- the interface included in OS X is bad, to say the least. He was apparently hoping that it would be better in Leopard, but no dice -- we're all using the new version, and it's still a pain to access the Keychain with AppleScript.So he's updated UKS to version 1.0b3. It's still a free download (and I'm guessing he still hasn't added the ability to set values of Keychain items, but only because he was justifiably worried that doing something wrong would have terrible consequences). If you've already been using it, you should be happy to see a new version, and if you haven't tried it yet, but do a lot of Keychain scripting, hopefully it'll make the interface a little less painful.

  • AppleScript: Finder commands

    by 
    Cory Bohon
    Cory Bohon
    12.29.2007

    Now that you've mastered the tell command, it's time to introduce some of the other AppleScript commands that you may encounter.Location commandThis command will allow you to open a specific location (either on your Mac or on a web server). This command is most often used with the Finder. For instance, if you wanted to open "www.tuaw.com," then you would type:tell application "Finder" to open location "http://www.tuaw.com"Remember, when dealing with an application always include quote marks around the application name. When you're typing a URL, be sure to include the prefix (HTTP:, AFP:, FTP:, etc.) and include quote marks around the URL. You can also tell a specific web browser to open the URL:tell application "Safari" to open location "http://www.tuaw.com"However, if you use the Finder version of the script, it will open your default browser.

  • AppleScript: the Script Editor

    by 
    Cory Bohon
    Cory Bohon
    12.27.2007

    Before you can build your first AppleScript you need to know some basics: what a script-able application is and how to use the Script Editor.Script-able ApplicationsBasically, script-able applications are applications in which the developer has included a set of "instructions" that the Script Editor understands and can use. Some apps are not script-able but most Apple apps are and, of course, Mac OS X itself is script-able.The Script EditorThe Script Editor is a very simple application, but it allows you to do some very powerful things. The Script Editor is located in your Applications folder (Applications : AppleScript : Script Editor.app) by default. The editor has a simple interface with a prominent text entry area. It also has 5 buttons in the toolbar; for now we will only focus on the "Run" and "Stop" buttons. The run button will run the currently typed script, and the stop button will cancel a running script.

  • Mac Automation: Automator for Leopard

    by 
    Cory Bohon
    Cory Bohon
    12.18.2007

    var digg_url = 'http://digg.com/apple/Mac_automation_Automator_for_Leopard'; A few people commented on my first Mac Automation post that they didn't understand Automator. This post will clear that all up. AppleScript is very powerful, but it has a learning curve. When Apple set out to make Automator, they tried to make an automation environment that not only gave the user flexibility, but also power. Apple includes several actions that programs can use; they also include a plug-in type model for developers of Mac software to add even more actions.

  • Automation on the Mac

    by 
    Cory Bohon
    Cory Bohon
    12.14.2007

    Welcome to the first of many AppleScript and Automator "how-tos." These tips are mostly geared toward Mac users who may know a little AppleScript, but want to learn more. If you've never opened Script Editor or Automator these tips will also help you get up to speed. First things first, what the heck is AppleScript? It is an easy-to-use and easy-to-learn programming language. AppleScript was created in the early 90s as a simple way for people to create their own custom automation programs. This is one of the reasons the Mac remains popular in the printing and creative industry, where users can take large work flows and automate them relatively quickly.

  • Grab Clean Leopard Window Shots with CleanGrab

    by 
    Erica Sadun
    Erica Sadun
    11.07.2007

    Ryan Irelan doesn't like the way Leopard grabs window shots. When you press Command-Shift-4/Spacebar, Leopard includes about 50 extra pixels of transparent background around your Windows. This extra space grabs the window's drop shadow along with the window itself. Enter CleanGrab. CleanGrab is Ryan's script for grabbing just the window, without the background pixels. He describes the script and offers a download link on his personal weblog. You'll either need to run the script directly or trigger it via a macro program like Quicksilver. The script essentially runs the command-line screencapture software using the -io flags. -i tells screencapture to run interactively. -o tells it to omit the window shadow. If you'd rather just use the terminal command-line, issue a screencapture -io command. I've posted about this handy utility a few times at least.