3 Replies Latest reply on Oct 14, 2017 4:49 AM by princeofparadaise

    Proposal: add Clipboard as content souce

    Dario de Judicibus Level 1

      Adding Clipboard as content source would have several advantages. For example, you could create a new document from clipboard and paste automatically the clipboard in that document. Ctrl-N,Enter would do the same trick.

        • 1. Re: Proposal: add Clipboard as content souce
          davescm Adobe Community Professional

          Hi Dario

          You can do that now albeit with one more key press.

          With an image on the clipboard just go to Photoshop and Press Ctrl+N, Enter then Ctrl+V

           

           

           

          Dave

          • 2. Re: Proposal: add Clipboard as content souce
            JJMack Most Valuable Participant

            Things like that can be scripted easily. You can do things like append the contents of the clipboard to a document and expand the document canvas for the size of the clipboards content and position the clipboard's contents over that area.

            /* ==========================================================
            // 2013  John J. McAssey (JJMack) 
            // ======================================================= */
            // This script is supplied as is. It is provided as freeware. 
            // The author accepts no liability for any problems arising from its use.
            
            
            // I set a shortcut key in my case F5 to this Photoshop script mainly for doing Window screen capturing of:
            // desktop displays, Active window and selected area copy to clipboard. The script log the cardboard into a document with the name clipboard. 
            
            
            /*
            <javascriptresource>
            <about>$$$/JavaScripts/AppendClipboard/About=JJMack's Append Clipboard into Clipboard document.^r^rCopyright 2014 Mouseprints.^r^rJJMack's Script.^r
            NOTE:New Clipboard Document will be open if necessary</about>
            <category>JJMack's Script</category>
            </javascriptresource>
            */
            
            
            // enable double-clicking from Mac Finder or Windows Explorer
            #target photoshop // this command only works in Photoshop CS2 and higher
            
            
            // bring application forward for double-click events
            app.bringToFront();
            
            
            if (!documents.length) {
            NewCliboardDoc (); 
            app.activeDocument.suspendHistory('appendClipboard','main(true)'); // New document opened proceed
            }
            else { //locate Document clipboard
            for (var i=0;i<app.documents.length;i++) { 
            app.activeDocument=app.documents[i];
            if (app.activeDocument.name == "Clipboard"){break;}
            }
            if (app.activeDocument.name != "Clipboard"){
            NewCliboardDoc ();
            app.activeDocument.suspendHistory('appendClipboard','main(true)'); // New document opened proceed
            }
            else {app.activeDocument.suspendHistory('appendClipboard','main(false)'); } // Old Clipboard Document found
            }
            
            
            ///////////////////////////////////////////////////////////////////////////////
            //                            main function                                  //
            ///////////////////////////////////////////////////////////////////////////////
            function main(newFile) {
            // declare local variables
            var orig_ruler_units = app.preferences.rulerUnits;
            app.preferences.rulerUnits = Units.PIXELS; // Set the ruler units to PIXELS
            
            
            try { 
            activeDocument.paste();    // past in clipboard may fail enclose in try
            var LB = app.activeDocument.activeLayer.bounds; // Get the bounds of the work layer
            var LWidth = (LB[2].value) - (LB[0].value); // Area width
            var LHeight = (LB[3].value) - (LB[1].value); // Area height
            // BOTTOMCENTER BOTTOMLEFT BOTTOMRIGHT MIDDLECENTER MIDDLELEFT MIDDLERIGHT TOPCENTER TOPLEFT TOPRIGHT
            if(newFile) {
            app.activeDocument.resizeCanvas(LWidth, LHeight, AnchorPosition.TOPLEFT);
            app.activeDocument.layers[1].remove();
            }
            else {
            if (LWidth>=app.activeDocument.width) { app.activeDocument.resizeCanvas(LWidth, app.activeDocument.height + LHeight, AnchorPosition.TOPLEFT);}
            else {app.activeDocument.resizeCanvas(app.activeDocument.width, app.activeDocument.height + LHeight, AnchorPosition.TOPLEFT);}
            }
            app.activeDocument.selection.selectAll(); // select all
            // Left('AdLf'); Right('AdRg'); Top('AdTp'); Bottom('AdBt'); Center Horizontal('AdCH'); Center Vertical('AdCV');
            align("AdLf");align("AdBt"); //Align to selection Left bottom
            app.activeDocument.selection.deselect();
            SetViewFitonScreen();
            //app.purge(PurgeTarget.CLIPBOARDCACHE);
            }
            catch(e) { 
            if(newFile) app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
            alert("Clipboard Empty"); 
            }
            
            
            app.preferences.rulerUnits = orig_ruler_units; // Reset units to original settings
            }
            ///////////////////////////////////////////////////////////////////////////////
            //                           main function end                               //
            ///////////////////////////////////////////////////////////////////////////////
            function NewCliboardDoc () {
            // app.documents.add([width][, height][, resolution][, name][, mode][, initialFill][, pixelAspectRatio][, bitsPerChannel][, colorProfileName])
            var Clipboard = app.documents.add( null, null, 100, "Clipboard", NewDocumentMode.RGB, null, null, null, "sRGB IEC61966-2.1");
            }
            
            
            function align(method) {
            var desc = new ActionDescriptor();
            var ref = new ActionReference();
            ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
            desc.putReference( charIDToTypeID( "null" ), ref );
            desc.putEnumerated( charIDToTypeID( "Usng" ), charIDToTypeID( "ADSt" ), charIDToTypeID( method ) );
            executeAction( charIDToTypeID( "Algn" ), desc, DialogModes.NO );
            };
            
            
            function SetViewFitonScreen() {
                var desc1 = new ActionDescriptor();
                var ref1 = new ActionReference();
                ref1.putEnumerated(charIDToTypeID('Mn  '), charIDToTypeID('MnIt'), charIDToTypeID('FtOn'));
                desc1.putReference(charIDToTypeID('null'), ref1);
                executeAction(charIDToTypeID('slct'), desc1, DialogModes.NO);
            };
            
            
            1 person found this helpful
            • 3. Re: Proposal: add Clipboard as content souce
              princeofparadaise

              SuspendHistory : does this work in VBSCRIPT

               

              Thanks