There's quite a lot you can do with custom scripting. There's a lot to learn and it's got kind of a steep learning curve at first because they have a lot of their own stuff, but it's pretty powerful and flexible.
Adobe's scripts are commonly written in Javascript but can also be written with ActionScript or VB.
Here's a list of resources to get you started:
- Adobe's Official Documentation
- Introduction PDF
- UI Guide for building dialogs (It is written for inDesign but there's a lot of overlap)