Using Automator and AppleScript to Easily Resize Windows

Having been an OS X user for only the past four or so years, I still find lots of interesting and useful tools packaged into the OS. One pair that keep popping up are Automator and AppleScript.

I regularly have the need to resize a window, easily, to a given resolution. This is usually in order to take a screen shot or record a screencast. I’ve always managed, but never with any real solid reusable solution.

Recently, in recording a new video that needed a 720p window, I decided I’d poke around and see what I could find for an easy and reusable way to accomplish this. I found several different apps that do similar, but what really caught my attention was a post that described how to resize a window in the built in AppleScript language/IDE.

I tried out the snippet of code, which worked great. However, since it works on the active window, I also needed a way to easily invoke the code without having the AppleScript window active. I decided I’d try to create a new item in the Services menu.

For those who don’t use OS X, Services menu items on a Mac are little applets that are available to any running application via the OS X menu bar. For instance, with a window active that can accept an image as input, the Services menu may have options to import from a Camera.

A bit more searching led me to Automator, another impressive tool that comes with OS X. Automator lets you create reusable workflows easily and visually. And, it also lets you create those workflows as a Service.

Armed with these tools, creating the new reusable Services menu item was easy.

To get started, fire up Automator. Choose the Service type for the new project.

Make sure you change “Service receives” to “no input” above the workflow. This will ensure the service is available for any type of window.

Next, search for and drag in an AppleScript action onto the workflow on the right.

With the AppleScript action in place, paste in the snippet of code for resizing the active window.

Finally, save the service. I named mine Resize Window to 720p.

Try it out! Now with any window active you can click the app’s main menu item, Services, Resize Window to 720p to resize the window automatically and easily.

2 thoughts on “Using Automator and AppleScript to Easily Resize Windows

  1. Tony Ring

    Pretty frustrating that you don’t just show the actual applescript – but rather a link to a site that gives some advice on how to write the script. I can see in your screenshot that you completed the actual script necessary. Why not just post it?


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>