Home / Articles / Adobe Photoshop / Learn How to Script Adobe Photoshop CS2

Learn How to Script Adobe Photoshop CS2

Chapter Description

This chapter demonstrates several techniques for creating scripts to use specifically with Adobe Photoshop CS2. More importantly, you'll learn how to use the Adobe Photoshop CS2 scripting references to find the objects, classes, properties, methods, and even some values (called constants or enumerations) you can use to create JavaScripts for Adobe Photoshop CS2.

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

var newDocRef = app.documents.add(8, 6, 72, "New Doc")

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.


Look up the copy() method in the Methods table for the ArtLayer and Selection objects in Part 2 of this book.

12. Working with units | Next Section Previous Section