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.
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.
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.
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 Files\Adobe\Adobe Photoshop CS5\Scripting\Utilities\ScriptListener.8li into C:\Program Files\Adobe\Adobe Photoshop CS5\Plug-ins\Automate
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 ...\Utilities\ScriptListener.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.