Keyboard Maestro Macro Image Resizer

Keyboard Maestro is an awesome application for anyomne who wants to automate their Mac. One of the less commonly known features is that there’s actually a way built into the application to generate a picture of a Keyboard Maestro macro. The challenge of late for me has been that since finally moving to a Macbook Pro with a retina screen, the resulting macro images have been very large. Too large for reasonable sharing in an e-mail or document in fact. The solution? A Keyboard Maestro macro of course.

The macro I created is effectively broken down into three fairly simple stages, and I opted to run it by use of a keyboard combination. I also put it within a Keyboard Maestro group so that it is only available when I’m in Keyboard Maestro.

Stage 1: Macro Image to Clipboard

The macro begins by setting the system clipboard to a text value - “Awaiting image from Keyboard Maestro …”. It then triggers a menu interaction in the Keyboard Maestro application to copy the current selection (which should be a macro), to the system clipboard as an image. After that, the macro checks that the system clipboard is now an image and will pause until it is.

I’d noted that very occasionally the macro would run too fast and the image would not have made it to the clipboard before the rest of the processing began. For this reason I added the initial text setting for the clipboard and the subsequent change to an image check.

Stage 2: Resize Clipboard Image

The next step in the macro resizes the image (of the macro) on the system clipboard to fit some maximum dimensions. I’ve set them as 800 wide and 4800 high, but you can obvously set them to meet your own requirements.

At this point we have an appropriately sized macro image on the system clipboard.

Stage 3: Wrap-up

The final set of steps is mainly about lettihng me know that the image is ready, but also a little bit of house keeping for the clipboard.

Now we have the image, I use an action to grab the actual dimensions of the clipboard image and put this into a variable. The macro then deletes the system clipboard entry two before the current entry. The curent entry is the resized image. The previous entry was the original image, and the entry before that, the one to be removed, is the text entry about waiting for an image that I put in at the start. Clearing this up keeps me from having lots of such temporary entries in my clipboard history.

Finally, a notification is displayed, letting me know the image dimensions, and that processing has been completed. At this point I’m free to paste the resized image into its destination.

The Macro

You can of course download the macro, but it would be remiss of me not to use the macro itself to generate an image of itself, so here it is.

Author: Stephen Millard
Tags: | keyboard maestro |

Buy me a coffeeBuy me a coffee

Related posts that you may also like to read