Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Applescript to JSX

New Here ,
Jan 14, 2022 Jan 14, 2022

Hey there!

 

I was using Photoshop for years on my Mac, but recently moved to a more powerful Windows PC. So unfortunately all my time saving Applescripts are not working any longer -  like this one here:

 

tell application "Adobe Photoshop 2020"

  activate

  set Doc_Ref to the current document

  tell Doc_Ref

    set theClippingPath to path item 1

    create selection theClippingPath feather amount 0.5 with antialiasing

    deselect path item 1

    delete path item 1

    cut selection

  end tell

end tell

 

Does anybody know how I can "translate" this one to a .jsx file, so I can run the script on my windows machine.

TOPICS
Actions and scripting , Windows
402
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
Jan 14, 2022 Jan 14, 2022
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2022 Jan 14, 2022

I don't know of any automated converter. I'm guessing that the two languages are just too different. Automated search/replace to change key words would be possible, however, I'm guessing that only simple scripts would translate and work correctly. More time would likely be spent debugging a conversion than simply rewriting in the required language. It can be hard enough translating between human languages, computer langauges are not as forgiving.

 

Let's look at one simple line of code, top row AppleScript, bottom row JavaScript/ExtendScript:

 

set

Doc_Ref

to the current document

var

Doc_Ref

= app.activeDocument;

 

Did you write the AppleScripts yourself?

 

Do you know JavaScript?

 

Do you know how to create actions? Actions would need to have "helper scripts" to work around limitations, such as selecting the first path by index number and not by absolute name. But an action could then do everything else. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2022 Jan 14, 2022

A literal "translation" from AppleScript would be similar to the code below. I don't know how to write AppleScript, however it is easy enough to read simple code.

 

#target photoshop
var doc = app.activeDocument;
doc.pathItems[0].makeClippingPath(); // why when it is deleted later?
doc.pathItems[0].select();
doc.pathItems[0].makeSelection(0.5, true, undefined);
doc.pathItems[0].deselect(); // why deselect the path?
doc.pathItems[0].remove(); // why delete?
doc.selection.cut();

 

Why make a clipping path, when the clipping path is deleted? 

Why deselect the path?

Why delete the clipping path?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2022 Jan 22, 2022
LATEST

Hey @pierres57154409 are you out there?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines