Within OS X 10.11.6, the Cmd ⌘ Shift ⇧ 4 key combination saves a screenshot to the desktop by default.
Is there a way to automatically copy the file to the clipboard (in addition to saving the file), so that the screenshot can be pasted into a document? Maybe there is some clever why to tee and pipe the image to the clipboard?
The intent is to:
- save screenshot to a file and
- copy screenshot to the clipboard
with a single command. Examples are always appreciated.
Best Answer
The following is an example of what I'd do, if I needed both, to place a screen shot on the clipboard and save it as a file at the same time.
I'd use Automator to create a Service1 workflow, to which a keyboard shortcut could be assigned, to run an AppleScript script to have these two events happen in conjunction with each other.
In Automator, create a new Service1 with the following settings:
with the example AppleScript code shown further below:
Now when you press ⇧⌘5 2 the crosshair cursor appears just as though you had pressed ⇧⌘4, however after making the selection as normal and releasing the mouse, the selected area is both copied to the clipboard and saved to a file on the Desktop.
macOS Mojave Update:
The file naming convention is that of the macOS default for Screen Shots saved normally, in my region. You may need to adjust the following line of code for it to be as in your region:
In my region, this command produces the following example output where the value of the
theDateTimeNow
variable would be, e.g.:Between the line of code above and the two lines that follow it in the script, they produce, e.g.:
In Terminal, have a look at the man page for both
date
andstrftime
, in order to make adjustments to format the date and time value of thetheDateTimeNow
variable, as needed or wanted.Note: Read the comments throughout the example AppleScript code so as to understand what the script is doing.
This was tested under macOS 10.13.1 and worked for me without issue.
Example AppleScript code:
Note: The example AppleScript code above is just that, and sans the include error handling does not include any other as may be appropriate/needed/wanted, the onus is upon the user to add any error handling for any example code presented and or code written by the oneself.