Automating Photoshop With C# which uses a COM reference to control Photoshop from another program.
The documentation for scripting with CS4/CS5 is pretty decent, covers a lot of areas, and has worked great for me until today.
Doing Something "Advanced"
Today I needed to add a black "Color Overlay" to a layer. To do this manually, I would:
1) right-click a layer and choose "Blending Options"
2) check "Color Overlay"
3) choose the color
4) press "OK"
I soon found that blending options and color overlays are not covered in the 233 page doc. But wait… they can be automated (with PS actions) so it seems like I should be able to script it.
Creating a Script from an Action
If you've got an action then you can easily create a script from it. Just copy & paste this script into ExtendScript Toolkit. (If you don't know what ESToolkit is, check out this post)
When you run that script, it creates a little dialog where you select your action. Once you're finished, the script will be saved to your desktop.
This method actually has different, better results than the next one.
Create a Script from What You Do
There's also a nice little plug-in that comes with CS5 that lets you just work in Photoshop as normal and it creates a script as you work. See the link for details, but installation worked like this for me:
1) Copy C:Program FilesAdobeAdobe Photoshop CS5ScriptingUtilitiesScriptListener.8li into C:Program FilesAdobeAdobe Photoshop CS5Plug-insAutomate
2) Restart Photoshop
Don't leave it turned on forever. You'll build up very large log files as you work and it may slow you down.
To uninstall, just delete …UtilitiesScriptListener.8li
In some cases, you will do something that will not generate any code script. In these cases, use the previous section (converting actions to scripts) since it has better results.