Put Latest Screenshot on Clipboard

On the Mac Power Users G+ group, someone asked:

Is there a scriptable/automated way for to attach my last screenshot to a Mail message? I'm constantly dragging screenshots (which get saved to the Desktop) into messages. I'd love a keyboard shortcut within the message that attaches the latest screenshot wherever the cursor is.

This seemed like an interesting challenge, so I put together a Keyboard Maestro macro to do this.

Customized Screen Capture preferences? No problem.

It is build primarily around a shell script (quelle surprise). It tries to be smart, so if you have changed:

  1. The default folder where screen shots are stored (defaults read com.apple.screencapture location)
  2. You have changed the type of image used for screen shots (defaults read com.apple.screencapture type)
  3. You have changed the default “prefix” for screen shots (defaults read com.apple.screencapture name)

It will still find any screenshots that match.


If it does not find any screenshots which match, it will tell you, using Growl (if Growl is running) or OS X notifications. (Growl notifications work better because they show more text than OS X notifications.)

Paste, if possible

The macro also checks to see if the current app has a Paste menu item enabled. If it does, the image will be pasted. So, for example, if you sending an email, it will attach the screenshot.

If the Paste menu item is not found or not enabled, a notification tells the user that the pasteboard now contains the latest screenshot image.

Credit to Chris Johnsen whose AppleScript I used to build this macro around: http://apple.stackexchange.com/a/15542/9226.

Download the macro here: Put Latest Screenshot on Pasteboard.kmmacros (9.2 KB)

Note that you may wish to limit this macro only to apps where you are most likely to use it, but I have made it a global using ⌃⌥⌘V as the keyboard shortcut.

This is what it looks like:

I was the one who made the request on G+, so thanks again for all your work on this. (As a result I’ve downloaded and installed KM and queued up the Mac Power Users episodes on the software.)

I hope you don’t mind a follow-up to ask for a bit of help getting it to work for me. I’ve got the Macro installed and running; I just changed the hot key. I take a screenshot (“Screen Shot 2015-09-09 at 15.50.00 .png”) and it lands on the Desktop (my default folder). Then in my Mail message I run the Macro and get the “Error Trying to Add Last Screenshot…” message.

Could it be my screenshot’s filename? It has a space and a hidden extension.


Shouldn’t matter about the space or hidden ext.

Can you run this line in Terminal.app and post the results?

defaults read com.apple.screencapture

(This just shows what your settings are.)

Hmm. That’s odd; I get this:

Domain com.apple.screencapture does not exist


That’s not actually that odd, all it means is that you have not
customized anything.

Curious. Still, the macro won’t work for me and I’m not sure why.

Wouldn't this simpler system work? All I need is another macro that tells Finder to select the most recently added or modified file.

Of course, that introduces a new problem! I've hit a wall trying to figure out how to do that.<img

I can't get it to work this end, I keep getting the following message in Notification Centre, any ideas?

Change the shell script’s output from “Display Briefly” to “Display in
Window” and you will get the full error message. If you can post that, I
might be able to see what it’s saying. (Right now it’s just showing you
the “${TMPDIR}” path, which is just the first part of the message)

Have you tried:

Command+Control+Shift+3 (screenshot all screens)
Command+Control+Shift+4 (screenshot selection)

These will automatically add your screenshot to your clipboard. Just paste it wherever you want.

1 Like

5 years later: