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.