How can I get the foreground color in Photoshop with AppleScript? Preferably in hex format.
There's a bug in CS5 where most of the Applescript terminology doesn't get loaded under some conditions: Adobe Forums: Changes to Photoshop CS5 and Applescript. I'm also experiencing it, but some of the suggested fixes (Opening PS in 32 bit mode, opening PS before ASE) didn't work for me. I didn't try reinstalling.
There's also an AppleScript Reference for CS5, see Adobe Photoshop Scripting | Adobe Developer Connection.
Get the color using
It should work with something like the following; I don't have PS to test it though: