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.

Advertisements

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?

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s