Skip to main content
Participant
June 3, 2022
Open for Voting

Feature request: Auto Paste when creating Clipboard-sized file

  • June 3, 2022
  • 5 replies
  • 812 views

I do a lot of annotation of screen snips in Photoshop, so when creating a new file I often use the current Clipboard dimensions. It's not a big deal, but it would be cool if the current Clipboard contents would be automatically pasted into the new project when that New Document setting is used. That would save me from having to press Ctrl-V, thereby speeding up my workflow by a microsecond or two.  🙂

 

Could that be possible?

 

Thank you for considering it!

 

Rick Hohmann

[Personal information removed by moderator ]

5 replies

Participant
June 8, 2022

Hi again Stephen!

 

Yes, that script launched by the Events Manager works great! I added a confirm() call to ask if the automatic paste is desired and it does exactly what I need now.

 

Thank you (and Michael Hale) so much!

 

Here's what I have now:

/*
New Document from Clipboard Content.jsx
https://community.adobe.com/t5/photoshop-ecosystem-ideas/feature-request-auto-paste-when-creating-clipboard-sized-file/idc-p/12984246
v1.0 - 4th June 2022, Stephen Marsh
v1.0.1 - 8th June 2022, Rick Hohmann (added if-confirm to give the user the opportunity to skip the automatic paste)
*/

#target photoshop

if (confirm("Do you want to paste the Clipboard?")) {
    try {
        // New Doc from Clipboard - Courtesy of the late Michael L. Hale
        var desc = new ActionDescriptor();
        var desc1 = new ActionDescriptor();
        desc1.putString(stringIDToTypeID("preset"), "Clipboard");
        desc.putObject(charIDToTypeID("Nw  "), charIDToTypeID("Dcmn"), desc1);
        executeAction(charIDToTypeID("Mk  "), desc, DialogModes.NO);
        // Paste the clipboard contents
        activeDocument.paste();
        // Flatten
        activeDocument.flatten();
        // Promote the Background to a standard layer
        // activeDocument.activeLayer.isBackgroundLayer = false;
    } catch (error) {
        alert("The clipboard is empty or does not have suitable content to create a new document!");
    }
}
Participant
June 8, 2022

Sorry Stephen! I didn't see your replies. I will try out the script today!

Stephen Marsh
Community Expert
Community Expert
June 8, 2022

@Z by HP Workstations – So how did the script work for you?

Stephen Marsh
Community Expert
Community Expert
June 4, 2022

@Z by HP Workstations 

 

Try this script:

 

/*
New Document from Clipboard Content.jsx
https://community.adobe.com/t5/photoshop-ecosystem-ideas/feature-request-auto-paste-when-creating-clipboard-sized-file/idc-p/12984246
v1.0 - 4th June 2022, Stephen Marsh
*/

#target photoshop

try {
    // New Doc from Clipboard - Courtesy of the late Michael L. Hale
    var desc = new ActionDescriptor();
    var desc1 = new ActionDescriptor();
    desc1.putString(stringIDToTypeID("preset"), "Clipboard");
    desc.putObject(charIDToTypeID("Nw  "), charIDToTypeID("Dcmn"), desc1);
    executeAction(charIDToTypeID("Mk  "), desc, DialogModes.NO);
    // Paste the clipboard contents
    activeDocument.paste();
    // Flatten
    activeDocument.flatten();
    // Promote the Background to a standard layer
    // activeDocument.activeLayer.isBackgroundLayer = false;
} catch (error) {
    alert("The clipboard is empty or does not have suitable content to create a new document!");
}

 

 

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not in a word processor)
  3. Paste the code in
  4. Save the text file as .txt
  5. Rename the file extension from .txt to .jsx
  6. Install or browse to the .jsx file to run (see below)

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html#Photoshop

 

Stephen Marsh
Community Expert
Community Expert
June 4, 2022

@Z by HP Workstations 

 

I have upvoted, I think that this is a useful additional feature request/idea. I do many of my screenshot annotations in Apple Preview, which has this feature (my screenshots generally come from saved files, so I rarely use the New from Clipboard option).

 

One workaround, you can set up the Script Events Manager to use the paste command from an action or script whenever a new document is created. I'm not sure if it is possible so that this only happens when the clipboard document setup is used.

 

https://prepression.blogspot.com/2021/10/photoshop-script-events-manager.html