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

Getting started using ExtendScript

Participant ,
Mar 31, 2019 Mar 31, 2019

Copy link to clipboard

Copied

I wanted to experiment writing some Photoshop scripts so I downloaded ExtendScript, created a couple of very simple scripts, saved them to the script location and verified that they actually ran. Once I verified that the pieces all worked (ie, ExtendScript was properly installed, I knew where to place the scripts and how to call them) I decided to write something more involved, and that meant that I wanted to run the scripts from ExtendScript rather than create a script, copy it to the scripting location and running it through Photoshop, and that is where I ran into some issues.

I opened Photoshop, opened ExtendScript, opened the scripting documentation that came with ExtendScript and created the first single line script in the document - app.documents.add(), and pressed Run. I got an error. -

Cannot execute script in target engine 'main'!

(#1116) Can't start debug session.

It seems clear to me that I am missing something fairly basic. The ExtendScript app is set to Photoshop and main, but will not run even a simple one statement script without an error, so something pretty basic must be wrong. Interestingly enough it (sometimes) actually created the document, sometimes did not, but always gave the error, even when the document was created.

ExtendScript.jpg

Hence this post and a couple of very basic questions:

1) What do I have to do to get a script in ExtendScript to run? What settings are wrong in the app?

2) Is there a basic starting guide to explain how to use ExtendScript as a debugging tool? If so, where? As I mentioned I was following the instructions in the Adobe Introduction To Scripting document word for word and still got this error.

3) Can regular javascript and the Adobe version be mixed seamlessly in a single script (or multiple script libraries) so that a script can control both Photoshop and other non-Adobe applications on a system? Or do I have to create different scripts for Photoshop and OSX usage (I am working on a Mac)?

Thanks for any help.

TOPICS
Actions and scripting

Views

2.9K

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Mar 31, 2019 Mar 31, 2019

Seems you have run into an issue that has been discussed in the following thread.

Extendscript Toolkit debugger fails on Mac: Can't start debug session

Try the solution proposed and see it resolves your problem. You could also try the VSCode extension mentioned in this thread.

As regards using extendscript with JS for non Adobe application, one way is that you can mix platform specific scripting like Applescript on MAC and VBScript on Win to automate other non Adobe applications. Look into the doS

...

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 31, 2019 Mar 31, 2019

Copy link to clipboard

Copied

Seems you have run into an issue that has been discussed in the following thread.

Extendscript Toolkit debugger fails on Mac: Can't start debug session

Try the solution proposed and see it resolves your problem. You could also try the VSCode extension mentioned in this thread.

As regards using extendscript with JS for non Adobe application, one way is that you can mix platform specific scripting like Applescript on MAC and VBScript on Win to automate other non Adobe applications. Look into the doScript method of application. However you won't be able to directly access the functionality exposed by other application into your JSX code.

-Manan

Votes

Translate

Translate

Report

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
Participant ,
Mar 31, 2019 Mar 31, 2019

Copy link to clipboard

Copied

Thanks for the link. I did a search before I posted, but did not see that, but changing the value does seem to have fixed the issue. The thread referred to the 18 November 2018 date, but apparently the issue exists beyond that date as well. Seems a bit of a surprise that Adobe has not fixed this issue.

In my particular case I was investigating the idea of allowing Photoshop to call an external tool that is not a plugin, wait for the tool to complete and then reload the image. That would require that I (1) save the image as a temp file, (2) start the other app with the image as a parameter, (3) wait for the app to complete and then (4) reload the image. An acquaintance asked me if this was possible and I decided to use it as an excuse for learning some javascript.

Items (2) and (3) would require OSX coding to launch the app and wait for its exit and update of the file, and thus presumably would be javascript (or AppleScript or vbscript). Since ExtendScript is the Adobe stuff I assumed that either I could also write javascript in ExtendScript or call a separate js script, but am not familiar with the toolkit or, for that matter, javascript itself, although I used to write java code so I assume javascript should be closely related to it and relatively easy to pick up.

Again, thank you for the link.

Votes

Translate

Translate

Report

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
Explorer ,
Aug 16, 2020 Aug 16, 2020

Copy link to clipboard

Copied

This did not work and I cant run anything in my extendscript toolkit

Votes

Translate

Translate

Report

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
Advocate ,
Aug 16, 2020 Aug 16, 2020

Copy link to clipboard

Copied

In the past, ESTK uses the file PCD.db from %appdata%/Adobe/Adobe PCD - C:\Program Files (x86)\Common Files\Adobe\Adobe PCD

 

You can try to compare this file with one from another user. Maybe there are some values missing.

I don't now have photoshop 2020 installed, so it doesn't make sense to post my file here, but maybe another user will be so nice., and can confirm that the reason are the missing values.

Votes

Translate

Translate

Report

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
Enthusiast ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

LATEST

Disclaimer: this is all my opinion and some people will likely disagree. Use it if it works, or ignore.

 

First, to anyone asking this question before or in the present, I would not recommend using ES Toolit. I've never touched an IDE so lousy. I wouldn't even recommend it for writing a text document. It is simply awful. Of course it (supposely) has debugging features we (supposely) need. In times I have tolerated its awful performance to use its debugging capability, the experience has been a major let-down compared to many other good IDEs for other languages.

 

Instead use VS Code. It does have a plug-in for ES but I still haven't got it to work yet. Probably just me and if anyone wants to chime in on tips to make it actually work, let us hear you. At any rate, the editing experience is 1000% better than ES toolkit. Especially if you use the "Types for Abobe" add-ons. See https://www.codeandmotion.com/blog/visual-studio-code-adobe-extendscript . It is great having code completion for ES.

 

Another thing to consider is that ES Toolkit is abandonware at this point. It is 32-bit and while it can still run on Windows (for now), recent macOS is now strictly 64-bit it won't even launch the app. It's time to move on.

 

About debugging ES it's not that difficult to simply use alerts, like when doing web dev and using console.log. Yeah, yeah, I know someone will come along and ridicule the practice but I'm about getting the job done. I don't get uptight about how. Least path of resistence. And ES Toolkit is a LOT of resistence in my opinion.

 

So here is what I'd recommend to beginners of coding ES.

 

First, make a simple script to get started.

alert("Hello World");

Save as whatever .jsx. For example, test.jsx. Save this wherever you like. Documents, Download, or a folder you create for scripts. Doesn't matter.

 

Next, go to Photoshop, make an action, in set of your choice (or create one just for scripts) and name however you like, maybe "Test". The action is now recording -- go to File menu, Scripts, Browse... to the script you just made. A dialog should appear "Hello World". Stop recording. Now you have an easy way to run your test as you develop.

 

Now edit your test script, remove the nonsense and add your first ideas, and try it out. All you have to do is run the action. You may get error messages, or sometimes nothing at all happens. That's an error too, but not always they are reported. If you encounter this and can't figure it out, wrap your code in a try/catch and in the catch alert the error, like this...

try {

    // your test code here

} catch (e) {
    alert("An error has occurred.\nLine " + e.line + ": " + e.message);
}

This will give you the line number making the trouble, and a description of the error that is helpful (hopefully). Now use alerts to get values of variables as you would in a debugger, to give clues as to what is behind the flaw.

 

That's a start. There is a lot more, like finding online the Photoshop DOM reference. Don't have the URL off-hand (my copies are on local server).

 

 

William Campbell

Votes

Translate

Translate

Report

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