- Viewing Photoshop CS2 objects, commands, and methods
- Creating new objects in a script
- Setting the active object
- Opening a document
- Saving a document
- Setting application preferences
- Suppressing dialog boxes
- Working with the Adobe Photoshop CS2 Object Model
- Working with color objects
- Working with filters
- Understanding clipboard interaction
- Working with units
- Sample workflow automation JavaScripts
- Advanced scripting
Understanding clipboard interaction
The clipboard methods in Adobe Photoshop CS2 operate on ArtLayer and Selection objects. The methods can be used to operate on objects within a single document, or to move information between documents.
The clipboard methods of the ArtLayer and Selection objects are:
- copy()
- copy(merge parameter value)
- paste()
- paste(intoSelection parameter value)
- cut()
Using the Copy and Paste methods
The following example copies the contents an the background layer to the clipboard, creates a new document, and then pastes the clipboard contents to the new document. The scripts assume that there is a document already open in Adobe Photoshop CS2 and that the document has a background layer.
//make firstDocument the active document var docRef = app.activeDocument docRef.artLayers["Background"].copy() var newDocRef = app.documents.add(8, 6, 72, "New Doc") newDocRef.paste()
Using the Copy Merged method
You can also perform a merged copy to copy of all visible layers in the selected area. In JavaScript, you must use the ArtLayer or Selection object’s copy() method with the merge parameter. To perform the merged copy, you must enter, or pass, the value true, as in the following example.
docRef.selection.copy(true)
Look up the copy() method in the Methods table for the ArtLayer and Selection objects in Part 2 of this book.