Adobe 65048332 Scripting Guide - Page 55

Using the copy merged command/method, Adobe Photoshop CS5 Visual, Basic Scripting Reference

Page 55 highlights

CHAPTER 3: Scripting Photoshop Understanding Clipboard Interaction 55 NOTE: If your script creates a new document in which you paste the clipboard contents, be sure the document uses the same ruler units as the original document. See "Setting Application Preferences" on page 32 for information. AS NOTE: On Mac OS, Photoshop must be the front-most application when executing these commands. You must use the activate command to activate the application before executing any clipboard commands. VBS tell application "Adobe Photoshop CS5" activate select all of current document copy set current layer of current document to layer "Background" ¬ of current document set newDocRef to make new document paste newDocRef end tell 'make firstDocument the active document Set docRef = appRef.ActiveDocument docRef.ArtLayers("Background").Copy Set newDocRef = appRef.Documents.Add(8, 6, 72, "New Doc") newDocRef.Paste JS //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 command/method You can also perform a merged copy to copy all visible layers in the selected area. In AppleScript, you use the copy merged command. For VBScript and JavaScript, you use the Copy/copy command, passing in a value of True/true for the optional merge parameter. AS NOTE: On Mac OS, Photoshop must be the front-most application when executing these commands. You must use the activate command to activate the application before executing any clipboard commands. set docRef to make new document make new art layer of docRef select all of docRef copy merged selection of docRef VBS docRef.Selection.Copy True Look up the Copy method for the ArtLayer and Selection objects in the Adobe Photoshop CS5 Visual Basic Scripting Reference, or in the Visual Basic Object Browser JS docRef.selection.copy(true) Look up the copy() method for the ArtLayer and Selection objects in the Adobe Photoshop CS5 JavaScript Scripting Reference, or in the ExtendScript Object Model Viewer.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87

C
HAPTER
3: Scripting Photoshop
Understanding Clipboard Interaction
55
N
OTE
:
If your script creates a new document in which you paste the clipboard contents, be sure the
document uses the same ruler units as the original document. See
“Setting Application Preferences” on
page 32
for information.
AS
N
OTE
:
On Mac OS, Photoshop must be the front-most application when executing these commands. You
must use the
activate
command to activate the application before executing any clipboard commands.
tell application "Adobe Photoshop CS5"
activate
select all of current document
copy
set current layer of current document to layer "Background" ¬
of current document
set newDocRef to make new document
paste newDocRef
end tell
VBS
'make firstDocument the active document
Set docRef = appRef.ActiveDocument
docRef.ArtLayers("Background").Copy
Set newDocRef = appRef.Documents.Add(8, 6, 72, "New Doc")
newDocRef.Paste
JS
//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 command/method
You can also perform a merged copy to copy all visible layers in the selected area. In AppleScript, you use
the
copy
merged
command. For VBScript and JavaScript, you use the
Copy/copy
command, passing in a
value of
True/true
for the optional
merge
parameter.
AS
N
OTE
:
On Mac OS, Photoshop must be the front-most application when executing these commands. You
must use the
activate
command to activate the application before executing any clipboard commands.
set docRef to make new document
make new art layer of docRef
select all of docRef
copy merged selection of docRef
VBS
docRef.Selection.Copy True
Look up the
Copy
method for the
ArtLayer
and
Selection
objects in the
Adobe Photoshop CS5 Visual
Basic Scripting Reference
, or in the Visual Basic Object Browser
JS
docRef.selection.copy(true)
Look up the
copy()
method for the
ArtLayer
and
Selection
objects in the
Adobe Photoshop CS5
JavaScript Scripting Reference
, or in the ExtendScript Object Model Viewer.