When I first started writing scripts for Photoshop, I used a plain old text editor. It worked fine, but it was a somewhat laborious task to write the scripts and then switch over to Photoshop to test them. Plus, troubleshooting the scripts was a difficult process, as well. Then I discovered the ExtendScript Toolkit in Photoshop CS2. Thankfully, it's a script editor that was created specifically for editing scripts in Photoshop and it really helps speed things up. Step OneFirst, you'll need to find the ExtendScript Toolkit. You may have even seen it before but not known it. On the Mac, go to Hard Drive:Applications:Utilities:Adobe Utilities:ExtendScript Toolkit. In Windows, you'll find it on your Start Menu, under All Programs>Adobe>ExtendScript Toolkit.
Step TwoOpen the Toolkit editor. You'll see a window with Photoshop-like palettes on the left and a text editor on the right.
Step ThreeChoose File>New JavaScript. This will create a blank file with an area on the right ready for you to type.
Step FourType the text shown here into the text editor. This code creates a new dialog in Photoshop. I'd like to draw your attention to something, though. Look at Line 9. See how it contains the string dlg.txtName? This creates a text box in the new dialog for us to enter text. Behind the scenes, Photoshop is referring to this text box by its name, which is txtName. (Note: You can download this script at www.scottkelbybooks.com/speedclinic, in case you don't want to type in everything in Steps Four through Seven.)
Step FiveNow you'll need to test the script, which luckily is very easy when you're using the ExtendScript Toolkit. First, select Adobe Photoshop CS2 from the first pop-up menu on the top left. Next, click the Run button. Photoshop CS2 will be launched, if it isn't already. Then the window will switch over to Photoshop and your script will run behind the scenes. At this point, all we've done is create a dialog with a text box and a button. It should look like the dialog shown here.
Step SixThis dialog won't actually do anything yet, though. To make it actually do something, type in the code shown here between your original Line 1 and your original Line 3 (which becomes Line 20, as you can see here).
Step SevenNow the script is done. However, before you run it take a look at Line 16. Notice it refers to an action called Gallery Print. You can actually call actions from scripts to really enhance the power you have to automate things in Photoshop. In order to use this script, be sure to download the Gallery Print action (Speed Clinic.atn) from www.scottkelbybooks.com/speedclinic and load it into your Actions palette. If not, the script will not work. To load it into your Actions palette, first download the file into your Photoshop Actions folder, which is in Adobe Photoshop CS2's Presets folder. Then, from the Actions palette's flyout menu, choose Load Actions. In the resulting dialog, select Speed Clinic.atn and click Load. It should now appear at the bottom of your palette.
Step EightAfter you're done testing the script, you can name it "SpeedClinic" and save it into Photoshop CS2's Scripts folder, which is in the Presets folder. Then restart Photoshop, and it'll show up in the Scripts menu. ©MATT KLOSKOWSKI Step NineOpen a photo in Photoshop. Choose File>Scripts>SpeedClinic and type in your name or a name for the photo in the text box. Press the Run button, and watch Photoshop work its magic by adding the text you entered and creating a gallery print from your photo. You'd never be able to use dynamic text in an action like this. An action would always add the same exact text. With a script, you can choose the text each time you run it.
|