0

I am attempting to create an apple script which will automatically select a foreground colour from my current layer in photoshop. I believe that this script is what I am looking for: How do I make a photoshop action pick a color from the image?.

However photoshop wont let me select the script, so I am not sure where I have gone wrong.

After I copy and paste this script into applescript, is there anything else that I need to add for it to work on the latest photoshop?

2
  • I believe you should run it from the apple script editor Commented Apr 6, 2023 at 17:30
  • 1
    By the way, in the topic that you’ve linked the script is in JavaScript, not AppleScript. Commented Apr 6, 2023 at 18:16

1 Answer 1

2

That script is javascript and not AppleScript. They are two separate, distinct, scripting languages. (Like French and Spanish.... many similarities, but still quite different)

In general, one should not use Apple's ScriptEditor unless you wish to control the operating system in some manner. AppleScript is used to control the Apple operating system and Apple applications.

Adobe applications all use javascript to control Adobe applications. While it is possible to control Adobe applications through AppleScript, the script has to be written in the proper language for any AppleScript to function. It is not possible to just paste a set of javascript commands into Apple's ScriptEditor and have a functional AppleScript.

At the very least any AppleScript would need to call that javascript specifically within the AppleScript to control Adobe applications. But using AppleScript can often be unwarranted overhead if the desire is to merely automate Photoshop.

In short: You do not really need or want AppleScript here. AppleScript is simply overhead given that you have a (presumably) functional javascript and are not seeking to control the Apple operating system in any way.


Copy the script to a plain text file.. save the text file with a .jsx suffix. Then Photoshop will see the script. Whether or not the javascript works as desired is another matter.
(Important Note: Apple's TextEdit, by default, will save rich text. That is not what you want. You want plain text. You can change the TextEdit preferences to save plain text.)


You can check the help files related to scripting Photoshop for more information.

1
  • Ah I see. Thank you for your clear explanation, that worked! Commented Apr 7, 2023 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.