Adobe 65014293 Scripting Guide - Page 8

Photoshop Scripting Basics, Scripting Overview, Why use scripts instead of actions? - part number

Page 8 highlights

2 Photoshop Scripting Basics This chapter provides an overview of scripting for Photoshop, describes scripting support for the scripting languages AppleScript, VBScript, and JavaScript, how to execute scripts, and covers the Photoshop object model. It provides a simple example of how to write your first Photoshop script. If you are familiar with scripting or programming languages, you most likely will want to skip much of this chapter. Use the following list to locate information that is most relevant to you. ➤ For more information on the Photoshop object model, see "Photoshop Object Model" on page 11. ➤ For information on selecting a scripting language, refer to the Introduction to Scripting guide. ➤ For examples of scripts created specifically for use with Photoshop, see Chapter 3, "Scripting Photoshop" on page 21. ➤ For detailed information on Photoshop objects and commands, please use the reference information in the three reference manuals provided with this installation: Adobe Photoshop CS4 AppleScript Scripting Reference, Adobe Photoshop CS4 Visual Basic Scripting Reference, and Adobe Photoshop CS4 JavaScript Scripting Reference. NOTE: You can also view information about the Photoshop objects and commands through the object browsers for each of the three scripting languages. See "Viewing Photoshop Objects, Commands, and Methods" on page 21. Scripting Overview A script is a series of commands that tells Photoshop to perform a set of specified actions, such as applying different filters to selections in an open document. These actions can be simple and affect only a single object, or they can be complex and affect many objects in a Photoshop document. The actions can call Photoshop alone or invoke other applications. Scripts automate repetitive tasks and are often used as a creative tool to streamline tasks that might be too time consuming to do manually. For example, you could write a script to generate a number of localized versions of a particular image or to gather information about the various color profiles used by a collection of images. If you are new to scripting, you should acquaint yourself with the basic scripting information provided in the Introduction to Scripting manual. Why use scripts instead of actions? If you've used Photoshop Actions, you're already familiar with the enormous benefits of automating repetitive tasks. Scripting allows you to extend those benefits by allowing you to add functionality that is not available for Photoshop Actions. For example, you can do the following with scripts and not with actions: ➤ You can add conditional logic, so that the script automatically makes "decisions" based on the current situation. For example, you could write a script that decides which color border to add depending on 8

  • 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

8
2
Photoshop Scripting Basics
This chapter provides an overview of scripting for Photoshop, describes scripting support for the scripting
languages AppleScript, VBScript, and JavaScript, how to execute scripts, and covers the Photoshop object
model. It provides a simple example of how to write your first Photoshop script.
If you are familiar with scripting or programming languages, you most likely will want to skip much of this
chapter. Use the following list to locate information that is most relevant to you.
For more information on the Photoshop object model, see
“Photoshop Object Model” on page 11
.
For information on selecting a scripting language, refer to the
Introduction to Scripting
guide.
For examples of scripts created specifically for use with Photoshop, see Chapter 3,
“Scripting
Photoshop” on page 21
.
For detailed information on Photoshop objects and commands, please use the reference information
in the three reference manuals provided with this installation:
Adobe Photoshop CS4 AppleScript
Scripting Reference
,
Adobe Photoshop CS4 Visual Basic Scripting Reference
, and
Adobe Photoshop CS4
JavaScript Scripting Reference
.
N
OTE
:
You can also view information about the Photoshop objects and commands through the object
browsers for each of the three scripting languages. See
“Viewing Photoshop Objects, Commands, and
Methods” on page 21
.
Scripting Overview
A script is a series of commands that tells Photoshop to perform a set of specified actions, such as applying
different filters to selections in an open document. These actions can be simple and affect only a single
object, or they can be complex and affect many objects in a Photoshop document. The actions can call
Photoshop alone or invoke other applications.
Scripts automate repetitive tasks and are often used as a creative tool to streamline tasks that might be
too time consuming to do manually. For example, you could write a script to generate a number of
localized versions of a particular image or to gather information about the various color profiles used by a
collection of images.
If you are new to scripting, you should acquaint yourself with the basic scripting information provided in
the
Introduction to Scripting
manual.
Why use scripts instead of actions?
If you’ve used Photoshop Actions, you’re already familiar with the enormous benefits of automating
repetitive tasks. Scripting allows you to extend those benefits by allowing you to add functionality that is
not available for Photoshop Actions. For example, you can do the following with scripts and not with
actions:
You can add
conditional logic
, so that the script automatically makes “decisions” based on the current
situation. For example, you could write a script that decides which color border to add depending on