0

How can I get the foreground color in Photoshop with AppleScript? Preferably in hex format.

2 Answers 2

1

Usually tell app "Adobe Photoshop CS5" to foreground color should work.

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.

1
  • Thanks! I tried tell app "Adobe Photoshop CS5" to foreground color but it says "a class name can't go after this identifier" - I'm going to try the Forums as you suggest and see if there is a fix. If anybody else has had success with this please let me know :)
    – cwd
    Apr 16, 2011 at 21:11
1

Get the color using foreground color. See here (PDF link), pages 12 and 13, for examples on how to use it.

Convert using convert color (page 188).

It should work with something like the following; I don't have PS to test it though:

tell application "Photoshop"
    set fgColor to foreground color
    set fgHexColor to convert color fgColor to RGB Hex
end tell
3
  • That reference page you passed along is the perfect thing to use to answer this question. Unfortunately, the code is not working for me. Did you try it? Did it work for you? When I paste that into AppleScript editor and try and run it I get "Expected end of line but found class name" - apparently it has a problem recognizing the keyword "foreground color." I'm using CS5 and I replaced the cs4 with cs5 in the URL you posted and it has the same snippet you referenced - same error after trying that one, too. Thanks!
    – cwd
    Apr 16, 2011 at 15:01
  • @cwd See my answer: I don't have PS to test it though. You can try get foreground color; but I don't know enough AppleScript to say whether that can help.
    – Daniel Beck
    Apr 16, 2011 at 17:05
  • I remembered that from one of your previous answers but was still hopeful :) Maybe someone else knows. I tried google again after you posted the documented syntax but still didn't have much luck. Thank you for the answer though.
    – cwd
    Apr 16, 2011 at 17:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .