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

Changes to Photoshop CS5 and Applescript

Explorer ,
May 06, 2010 May 06, 2010

Copy link to clipboard

Copied

Looks like there are some major Applescript changes to CS5, which is unwelcome for anyone with existing scripts. From what I can see, the difference (that affect me anyway) are

a) PSCS5 seems to dislike referring to files with "as alias" and removing this from my scripts helps them to work, whereas other apps need it, as did previous

b) apparently script support for referring to the currently document has changed. "if visible layer of current document is true then..." no longer works, nor do document 0, document 1, etc. Anyone know how to refer to the current document?

c) support for history doesn't seem to be there anymore. I cannot seem to use AS commands like, "set myState to history states as list" or "set current history state to history state newState" were awesome for my workflow, but are they impossible to achieve now?

d) One more. The important "set docref to make new document with properties {height: 150, width: 150}" is also broken. How would one make a new document in Applescript?

TOPICS
Actions and scripting

Views

32.2K

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
Adobe
Explorer ,
May 06, 2010 May 06, 2010

Copy link to clipboard

Copied

They seem to have removed a huge number of AppleScript features, and the dictionary is basically empty. The developer center doesn't have any info on CS5 either: http://www.adobe.com/devnet/photoshop/scripting/ So apparently they expect us to just guess at what works.

Presumably they want us to start using JavaScript instead of AppleScript. But the worst part is that the "do javascript" command is apparently gone as well, which would have at least given us an easy way to transition existing scripts.

What a disaster.

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 ,
May 06, 2010 May 06, 2010

Copy link to clipboard

Copied

I just found the AppleScript documentation in /Applications/Adobe Photoshop CS5/Scripting/Documents/. But I don't think it's even accurate. Here's a very simple sample they give:

tell application "Adobe Photoshop CS5"      filter current layer of the current document using lens blur with options {class:lens blur, radius:13} end tell

If I enter this in AppleScript Editor and try to compile it, it selects the word "current" and tells me "Expected end of line but found identifier." It doesn't even recognize "filter" as a command. If I just change that 5 to a 4, it works fine in CS4.

Here's one way to run a JavaScript file from AppleScript:

tell application "Adobe Photoshop CS5" to open file "Path:to:file.jsx"

Of course there's no way to pass any arguments this way, so that greatly limits its usefulness. But perhaps this will be helpful to some people. I'm assuming the JavaScript stuff all works fine, as that seems to be their focus these days.

The really strange thing is that certain things seem to work fine in AppleScripts that are already compiled (using CS4). But if I try to re-save those scripts with CS5 installed, I get errors.

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
Guru ,
May 07, 2010 May 07, 2010

Copy link to clipboard

Copied

I'm assuming the JavaScript stuff all works fine, as that seems to be their focus these days.

It doesn't surprise me that there are errors in Applescript and/or it's documentation. There are errors in both javascript and it's guides.

I would surprise me if those errors are intentional to force anyone to switch to javascript.

My guess would be that any new Applescript errors are a result of either the Apple forced API change or the change to 64 bit. That combined with the fact that there are fewer Applescript developers for Photoshop to report any errors when the product was in prerelease.

I reported several javascript errors during the prerelease. Most where not fixed. I didn't assume that was because Adobe didn't want javascript developers. I assumed that they did not have time or resources to deal with those because of the other work needed for this cycle.

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 ,
May 07, 2010 May 07, 2010

Copy link to clipboard

Copied

Yeah, after investigating it further I think it's just buggy, as opposed to having features intentionally removed. I was finally able to get a complex script working again with minimal changes by doing this:

  • Installed Photoshop CS4 again.
  • Had my scripts call "Adobe Photoshop CS4" or just "Adobe Photoshop CS" rather than CS5.
  • If I was ever asked to locate Photoshop while compiling, I selected CS4, not CS5. Selecting CS5 here, or calling "Adobe Photoshop CS5" in the script will result in major errors.
  • Once the script was compiled (saved), I moved my Photoshop CS4 folder to the trash (without emptying it). This made sure the script ran in CS5. Then if I needed to make further changes, I could just drag CS4 out of the trash and back into place.
  • It was also a big help to add try… on error… end try blocks around things that seemed to be causing problems in CS5.

Peter, hopefully this will help you too. By doing the above I've found that "current document", "as alias", and other things work as expected in CS5, even though they were previously giving me errors.

Can anyone tell us the best place to report these bugs? I'd love to do what I can to help them get fixed.

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
Guru ,
May 07, 2010 May 07, 2010

Copy link to clipboard

Copied

You should be able to report bugs here https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform

You will need an Adobe ID, which you should already have.

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 ,
May 07, 2010 May 07, 2010

Copy link to clipboard

Copied

Thanks Michael, I just filed a bug report:

******BUG******

Concise problem statement:

Photoshop CS5 for Mac has some major issues with AppleScript. Most (but not all) scripts seem to run okay, but all of the custom commands are missing from the dictionary, and almost nothing will compile. The only workaround I've found is to install CS4, compile against that, then run the script with CS5.

Steps to reproduce bug:

1. Open AppleScript Editor

2. Enter a simple script from the AppleScript guide, like:

tell application "Adobe Photoshop CS5"

     filter current layer of the current document using lens blur with options {class:lens blur, radius:13}

end tell

3. Click Compile or Run.

Results:

An error occurs: "Expected end of line but found identifier."

Expected results:

The script should compile with no errors, or run--applying a lens blur to the front-most document in Photoshop CS5.

If CS5 is changed to CS4, the script works perfectly. (If it the script is saved as an application and CS4 is deleted, it will probably even work in CS5. Compiling is the main issue.)

For anyone else having problems I'd encourage you to do the same.

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
Adobe Employee ,
May 18, 2010 May 18, 2010

Copy link to clipboard

Copied

Besides information about the OS version could you also let me know:

- whether or not your are running in 32 bit mode

- which 3rd party plug-ins (if any) you are using

- which scripting additions that you are using

Thanks,

Jesper

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
Guest
May 19, 2010 May 19, 2010

Copy link to clipboard

Copied

- Mac OS X 10.6.3 french, CS5 french

- 64 bits mode

- no third parties plug-ins

OSAXEN : Adobe Unit Types.osax (from cs5 installation), Satimage.osax,XMLLib.osax (both are from sati image), SIMBL.osax,SmartScroll.osax,XMLLib.osax,TextExpander Addition.osax

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
Adobe Employee ,
May 20, 2010 May 20, 2010

Copy link to clipboard

Copied

D'accord.

Besides using a French version of Photoshop you should have the same version as I do. Could I ask you to post specific steps on how to repro from system restart to failure?

You'll see me test case earlier in this thread & that case does not fail on my system.

Thank you,

Jesper

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
New Here ,
May 20, 2010 May 20, 2010

Copy link to clipboard

Copied

Test case:

1. Place an "image.tif" on your desktop

2. Open another image in Photoshop

3. Run the following script

tell application "Adobe Photoshop CS5"

activate

set masterDocument to current document

open file ((path to home folder as string) & "Desktop:image.tif")

height of masterDocument

end tell

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
Guest
May 20, 2010 May 20, 2010

Copy link to clipboard

Copied

Just did Error

error "Erreur dans Adobe Photoshop CS5 : Il est impossible d’obtenir current document." number -1728 from current document

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
Adobe Employee ,
May 20, 2010 May 20, 2010

Copy link to clipboard

Copied

Thanks for the repro steps.

It appears that the "open" command affects the terminology.

In the following script the first "height of current document" works, while the second fails:

tell application "Adobe Photoshop CS5"

activate

height of current document

open file ((path to home folder as string) & "Desktop:image.tif")

height of current document

end tell

When we are in the failure mode everything fails so it does appear that Cocoa in some way is overriding our event handlers.
Again thanks for reporting this issue and providing a test case.

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
New Here ,
May 20, 2010 May 20, 2010

Copy link to clipboard

Copied

I'm glad to see you're getting what is going wrong.

If I can be of any help, please tell me! I'd love to see this fixed.

Thanks!

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
Adobe Employee ,
May 21, 2010 May 21, 2010

Copy link to clipboard

Copied

Based on the test case from this thread, we have been able to make some changes that solves the problems that we are seeing.

If you post your email I'd be happe to email you a pre-release version of the changes so you can verify whether or not it solves the problems that you are seeing on your system (the size is between 3 and 4 MB).

If you do post your email address make sure to scramble it slightly to minimize the risk of getting spam from web-crawlers.

For example: "tom" at "company dot fr"

Again, Thanks for your help.

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
New Here ,
May 21, 2010 May 21, 2010

Copy link to clipboard

Copied

Excellent, that was quick.

I'd be happy to test and report back to you.

I just sent you a private message with my e-mail address, is that ok?

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
Guest
May 21, 2010 May 21, 2010

Copy link to clipboard

Copied

Please send it at "vincentdigitallife"  gmail  dot com

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
Community Beginner ,
May 21, 2010 May 21, 2010

Copy link to clipboard

Copied

I'd be happy to kick it around, too.

richard (at) sidewaysdesign (dot) com

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 ,
May 21, 2010 May 21, 2010

Copy link to clipboard

Copied

For what it's worth I am no longer able to reproduce the problems I was having. It was happening very consistently until I reinstalled Photoshop CS4. Now, even after uninstalling CS4 again, I can't recreate the problem.

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
Guest
May 24, 2010 May 24, 2010

Copy link to clipboard

Copied

New plugin works great for me, thanks a lot !

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
New Here ,
May 28, 2010 May 28, 2010

Copy link to clipboard

Copied

hoping to try this patch as well. this bug has put a halt on my workflow

trapdoormg at gmail.com

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
New Here ,
May 28, 2010 May 28, 2010

Copy link to clipboard

Copied

thank you for the incredibly fast response jesper. the plugin solved my problems!!

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
Adobe Employee ,
May 28, 2010 May 28, 2010

Copy link to clipboard

Copied

You are welcome.

Thank you for letting us know that this change fixes the problem that you are encountering.

Jesper

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
New Here ,
May 28, 2010 May 28, 2010

Copy link to clipboard

Copied

When can we expect this patch to be pushed to every CS5 user out there?

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
New Here ,
Jun 02, 2010 Jun 02, 2010

Copy link to clipboard

Copied

Hi Jesper,

I ran across this discussion searching for a fix to my applescripting errors with Photoshop CS5. I was wondering if I could get that beta fix as well. You can email it to me at chrisbernal.design [at] gmail.com

Thanks in advance.

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