Example: Creating and Installing a Simple Script

I'm going to show you how even a former art major like me can create a simple yet useful script to change how Photoshop works. I don't have any programming experience, but the built-in tools will help me get it done. I came up with the idea for the following script after seeing an example on Jeff Tranberry's blog (blogs.adobe.com/crawlspace/2006/05/installing_and_1.html).

My script solves a specific problem. I use a laptop and often plug in an external monitor or projector. Every time the monitor configuration changes, Photoshop decides to reset the palettes the next time I open it. I'm quite picky about my palette arrangement, so it's annoying when my palettes aren't the way I like them. I've already saved my favorite palette arrangements as workspaces, and I realized that if I recorded a script that chose my favorite workspace, I can use the Script Events Manager to run the script every time Photoshop opens. That way, no matter what Photoshop wants to do with the palettes, my favorite workspace will be applied without my having to manually select my workspace every time.

Here's how I did it:


I install the Scripting Listener plug-in (see "Scripting Utilities" earlier in this chapter).


I start Photoshop.


I choose Window > Workspace > PowerBook monitor. That's the name of a workspace I created, so if you try this, choose the name of a workspace you created.


On my Mac OS X desktop, I double-click the file ScriptingListenerJS.log, which opens the log in the Console program (Figure 19.2). On my Windows desktop, I would navigate to c:/ and double-click ScriptingListenerJS.log, which opens the log in the Notepad program.

Figure 19.2.

  • I see a few lines of JavaScript code that recorded my workspace selection. I can see the name of my workspace in the code ("PowerBook monitor").


Because I can't edit text in the Console program I'm using, I copy and paste it into a text editor (TextEdit).


I add two lines to the top of the text: A description on the first line and a comment on the second line. I copied the format from one of the Photoshop sample scripts (Figure 19.3).

Figure 19.3.


I save the script as a text-only document with the filename Apply PowerBook workspace.jsx. The .jsx extension identifies the document as a JavaScript.

  • If I was going to run the script from the Scripts submenu, I'd save it in the Scripts folder (see "Loading Scripts"). However, because I plan to run this script only by using a Photoshop event to trigger it, I save it in the Event Scripts Only folder inside the Scripts folder.


I choose File > Scripts > Script Events Manager.


I choose Start Application from the Photoshop Event pop-up menu and choose Apply PowerBook Workspace from the Script menu.


I click Add, and the new event appears in the list at the top of the dialog box (Figure 19.4). Then I click Done.

Figure 19.4.


I test the script by moving some palettes around and restarting Photoshop. Sure enough, as soon as Photoshop loads, my palettes are arranged according to my PowerBook Monitor workspace. Success!

If you simply want to run a script from the File > Scripts submenu, you don't need to perform steps 8 through 11. As long as you've moved the script into the Scripts folder, just restart Photoshop, and the script appears on the File > Scripts submenu.

You can use the Scripting Listener plug-in to observe what happens when you change settings in dialog boxes and palettes. You can then use the code from the log to build scripts that open a dialog box and fill it with settings of your choice.

Working Smart in Adobe Photoshop CS2
Working Smart in Adobe Photoshop CS2
ISBN: 0321335392
EAN: 2147483647
Year: N/A
Pages: 161
Authors: Conrad Chavez

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net