Running Scripts

Anyone can run a script, because it's easy as choosing a menu command. You can try it right now, because Photoshop comes with some sample scripts.

To run a script from within Photoshop:


Open a test document (something expendable).


Choose File > Scripts.


Do one of the following:

  • Choose a script from the Scripts submenu, if any are listed.

  • Choose Browse to look for a script. The sample scripts that come with Photoshop are located inside the Adobe Photoshop CS2 application folder, in

     Scripting Guide/Sample Scripts/JavaScript. 


Click Load.

In this example, I pointed you to the JavaScript folder because you can open those from within Photoshop. AppleScript and VBScript scripts operate at the level of your operating system, so you can run those by double-clicking them from the desktop.

You can also trigger a script when a specific event happens in Photoshop. For example, you can use a script to control what happens when someone chooses File > Save. You set this up in the Script Events Manager.

To associate a script with an event:


Choose File > Scripts > Script Events Manager.


Make sure Enable Events to Run Scripts/Actions is enabled.


Choose an event from the Photoshop Event pop-up menu. For the Save example I mentioned, choose Save Document.

  • To use an event that isn't listed, choose Add an Event from the Photoshop Event pop-up menu. In the Add an Event dialog box, enter the Event Name and Descriptive Label. You must choose from the list of events in Appendix A of the Adobe Photoshop CS2 JavaScript Scripting Reference (see the section "Scripting Documentation" later in this chapter); the Descriptive Label must be one of the Event ID Codes listed in Appendix A.


Choose a script from the Script pop-up menu. For the example, choose Save Extra JPEG.jsx.


Click Add. The event you set up is added to the list at the top of the Script Events Manager dialog box (Figure 19.1).

Figure 19.1. Use the Script Events Manager to run any script when a specific event happens in Photoshop.


Click Done.

To test the Save example, open a test file, choose File > Save, and save the PSD file in a convenient location. Look in the folder where you store the original test documenta copy of the file with a .jpg filename extension should now exist next to it. (The sample script applies the last-used JPEG settings, as if you had chosen the JPEG file format and simply clicked Save.)

I use the Script Events Manager again later in another, more specific example.

To edit the list of Photoshop Events in the Script Events Manager, edit the file Script Events Manager.xml, located inside the Adobe Photoshop CS2 Settings folder.

Working Smart in Adobe Photoshop CS2
Working Smart in Adobe Photoshop CS2
ISBN: 0321335392
EAN: 2147483647
Year: N/A
Pages: 161
Authors: Conrad Chavez © 2008-2017.
If you may any questions please contact us: