MacMost Now 247: Using Automator to Playback Actions

Learn how to use Automator in Mac OS X Leopard to record actions and play them back. In this example, you'll see how to create an Automator script to save a Web page from Safari as a PDF.
Video Transcript / Captions
Closed captioning for this video is available on YouTube: MacMost Now 247: Using Automator to Playback Actions.

In today's episode, let's learn how to record a workflow using Automator.
So Automator is this handy tool you'll find in your applications folder that allows you to go ahead and create scripts that can do repetitive actions in OS 10 and using lots of different applications. You can also go ahead and record some actions just by simply performing them, and save that recording as a script and have it performed over and over again. Let's take a look at an example.
So here's an example. Suppose you're in Safari and you want to save a page as a PDF. Here's a page of technical specifications for the MacBook Pro at the Apple website. Say you want to save this as a PDF; one of the thing you would do is go to File, then you would go to Print, then you would click on the PDF button here at the bottom, and choose Save as PDF. And then you just file dialog and navigate to where you want to go to and save. That's a lot of steps to do, and if you're doing this a lot, you probably want to automate it. Let's look at how.
So when you first run Automator, you get a screen that looks like this. You're going to to choose Custom and then hit Choose. Now on the left here there's all these different commands that we can add to the right to create our script. We're not going to use that. Instead we're going to hit the Record button to record exactly what we do. So we're going to hit Record, then we're going to go down to the dock which you can't see and choose Safari, so Safari comes to the front. I'm now going to hit Command+P and it's going to bring up the print dialog. I'm going to click the PDF button there once, I'm going to move down and click the Save as PDF, then I'm going to navigate to a folder we're going to call PDFs. To do that, I'm going to use the search dialog over here, type in PDFs. It will appear as the only folder there in my results. Click on PDFs right there, and click Save. It's exactly what I wanted to do, so I'm going to press Stop, and now I can see my complete script on the right.
Now, it's important to really think about each command before you go ahead and record your script. For instance, everything here has a purpose. I'm clicking Safari in the dock; I'm not clicking on the Safari window, because this will ensure that Safari runs. If I clicked on the window it would actually be looking for a window of that title, which will change from page to page. Then I'm pressing Command+P, which seems to be more reliable than selecting File and then going down to Print, because doing the second will actually go ahead and follow your cursor movements, which sometimes can differ depending upon what's going on on your screen. Then I'm going to go ahead and click the PDF button. Now I'm going to click it once and bring up the pop-up menu, not click and drag down, because Automator doesn't seem to record that very well. Then I'm going to click a second time on the Save as PDF. Then I'm going to bring the Save window to the front; it already is in the front but I'm actually going to go ahead and drag it over, which is what you saw. I'm going to click on the text field there, which is the search text field, type in "PDFs". Now, I could have just clicked on PDF that was inside the save dialog, but perhaps it's not there. Perhaps the last time I saved something in Safari I saved it somewhere else and PDFs isn't available. By searching for PDFs I ensure that it'll show up on the screen so Auotmator can select it. I'm going to click the text "PDFs", which will set it to that folder, and click the Save button. Now, this should be a pretty repeatable set of steps no matter what Safari page you're on, no matter what else is going on, although it is possible to screw it up.
So the next thing I need to do is save this so I can reuse it. You can save it in a lot of different ways. You can save it as a little stand-alone application that will run; you can also save it as a plug-in, which is what I'm going to do. And I'm going to set it as a plug-in that will be in the Script menu. The Script menu will appear in the upper right-hand corner of your Mac; it looks like a little scroll icon that's near your clock in the upper right-hand corner of your screen. I'm going to save it as "SaveSafariToPDF". And I'm going to click Save.
So here I am on a different page in Safari, and I want to go execute the script. So I'm going to go off-screen here to the little script menu in the upper right-hand corner, and at the bottom I've got SaveSafaritoPDF, which you can't see, but when I click it you'll see the results. It automatically goes ahead and will switch back to Safari. Then it will go ahead and go to the print dialog, go to PDF, go to Save as PDF. It will bring up that save dialog, then it's going to go ahead and type "PDFs" in there. It's happening a little bit off-screen but you can see what's going on. Then you go ahead and select PDF and hit the Save button. And there, it's done. Now notice it took a long time to do that because it was playing back everything in exactly the same time as I originally recorded it. We can fix that, too.
So here, in Automator, if I scroll this window over to the right, you'll see that there's a timeout, a delay between actions, and also the playback speed for each action set at 1x. What I'm going to do is I'm going to select all the different actions there. Then I'm going to set a 0 timeout, and set it to play back everything at ten times the speed. Then I'm going to go ahead and save it as a plug-in, replace what was originally there.
So that's a look at how to create a recorded script using Automator so it can repeat something every time you need to. You can go ahead and create the script and save as PDF every time. You can also use it to do other actions that include multiple menus and multiple choices. It's really tricky to use Automator; you've got to kind of play around with it, get used to it, try things over and over again to really get the hang of it.
Until next time, this is Gary Rosenzweig with MacMost Now.

Comments: 5 Responses to “MacMost Now 247: Using Automator to Playback Actions”

    8 years ago


    7 years ago

    I just finished watching your video, and it explained a lot. I would however like to instead of telling the Automator to put files in a PDF folder I would like to:
    Go to an open safari page
    Save as PDF
    ….Then type in a unique filename
    then Save to desktop.

    Is it possible for you to help? I have an iMac with OS 10.7.3
    Thank you,

      7 years ago

      I don’t have any specific advice. The “type a unique filename” will be tough, but you should be able to create an action that does everything up to that point. Just a matter of trying, experimenting, getting to know the tool. Patience should yield results.

    7 years ago

    I am using OS 10.8.2 and save as plug-in does not show in the automator menu!?

      7 years ago

      Things have changed since this video was made in 2009. Try to create an Automator project as a Service. Then when you save it, it will appear in the Safari, Services menu if you do it right.

Comments Closed.