2 Replies Latest reply on Feb 11, 2010 11:58 AM by Yuliaart

    How to run ps cs4 js script from applescript

    Yuliaart Level 1

      Hi, I need to call photoshop js from applescript. Here what I have so far:

       

      tell application "Adobe Photoshop CS4"
          activate
          set myScript to "Applications:Adobe Photoshop CS4:Presets:Scripts:_NDF_Ph_saveAsTif.jsx"
          do javascript (myScript)
      end tell

       

       

      and it's compiles, but when runs, gives me "Error 25: Expected: ;." message.

       

      How can I call ps script from as.

       

      Thank you very much for your help.

      Yulia

        • 1. Re: How to run ps cs4 js script from applescript
          Muppet Mark Level 5

          You have 2 ways either JavaScript supplied as string or as file. If you are going the route of file then you need to coerce your path string to 'alias' this will fail if it does NOT exist. Here are 2 examples. You also have option to pass arguments as list.

           

          -- As String

          set JavaScript to "myTest();

          function myTest() {

          var docRef = app.activeDocument;

          var docWidth = docRef.width;

          var docHeight = docRef.height;

          var docSize = docWidth + ' x ' + docHeight

          return docSize

          }"

          tell application "Adobe Photoshop CS2"

          activate

          set Doc_Ref to the current document

          tell Doc_Ref

          do javascript JavaScript ¬

          show debugger on runtime error

          display dialog the result

          end tell

          end tell

           

          -- As File

          set ScriptPath to (path to applications folder as text) & "Adobe Photoshop CS2:Presets:Scripts:Hello.jsx" as alias

          tell application "Adobe Photoshop CS2"

          activate

          set Doc_Ref to the current document

          tell Doc_Ref

          do javascript ScriptPath ¬

          show debugger on runtime error

          end tell

          end tell

          • 2. Re: How to run ps cs4 js script from applescript
            Yuliaart Level 1

            This is great. I tried the alias one and it works, and I am sure I will be able to use the other one at some point.

             

            Thank you, Mark.