Preview's "New From Clipboard" Function from Terminal?

Is there a way to access Preview's "New From Clipboard" function from the command line? Or some other way to accomplish the same thing? I.e., open a new document containing the picture currently in the Clipboard?

Thanks in advance.

Posted on Feb 15, 2008 2:40 PM

Reply
3 replies

Feb 16, 2008 10:49 AM in response to Mark Jeffreys

Preview is not directly scriptable at all, either via shell scripts or AppleScript.

However, AppleScript has some system-wide abilities such as sending keystrokes to applications, therefore you can effect the same actions via something like:

<pre class=command>osascript -e 'tell application "Preview" to activate' -e 'tell application "System Events" to keystroke "n" using {command down}'</pre>

This uses osascript to run the AppleScript commands that launches Preview and issues Cmd-N, the keyboard equivalent of 'New from Clipboard'.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Preview's "New From Clipboard" Function from Terminal?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.