4 Replies Latest reply: Jan 14, 2010 10:31 PM by Jeff S GP2 RSS

    How to call a JavaScript in Photoshop?

    Jeff S GP2 Community Member

      Hello,

      I created 3 simple scripts (converted PS Actions to JavaScript) as a test:   Script1.jsx,  Script2.jsx,  Script3.jsx

      How would I go about creating another  JavaScript that runs these three JavaScript consecutively (while in photoshop)
      ..I can create a simple PS Action of opening the three scripts (which works)..  but  when I convert this back to a Javascript, I receive an error.

      My goal is for the ability to create a JavaScript that can call the three scripts.

      ie:
      call Script1.jsx
      call Script2.jsx
      call Script3.jsx

        Can this be done?

      Thanks for any help

      Jeff

        • 1. Re: How to call a JavaScript in Photoshop?
          Paul Riggott Community Member

          You could try this...

          var SCRIPTS_FOLDER =  decodeURI(app.path + '/' + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts"));
          var Script1 = File(SCRIPTS_FOLDER + "/Script1.jsx");
          var Script2 = File(SCRIPTS_FOLDER + "/Script2.jsx");
          var Script3 = File(SCRIPTS_FOLDER + "/Script3.jsx");
          $.evalFile (Script1);
          $.evalFile (Script2);
          $.evalFile (Script3);
          
          • 2. Re: How to call a JavaScript in Photoshop?
            Jeff S GP2 Community Member

            Thanks, Paul

            This works great!

            If i might trouble you for a minor addition?

            Currently the script directory path resides in the local application folder.
            How would this code be written to reflect a different directory path outside of the Application?

            ...Still running the script from photoshop, but say its calling the three scripts kept in:     Z:\ANIMATION\Max_Renders\FaceLevels\ActionsScripts

            (I'm trying numerous variations with no luck)

            many, thanks!

            Jeff

            • 3. Re: How to call a JavaScript in Photoshop?
              Paul Riggott Community Member

              Change SCRIPTS_FOLDER to:-

              var SCRIPTS_FOLDER =  "/z/ANIMATION/Max_Renders/FaceLevels/ActionsScripts";

              • 4. Re: How to call a JavaScript in Photoshop?
                Jeff S GP2 Community Member

                Thanks, Paul.

                Worked!...  with a slight modification.

                Received errors until I added a backslash at the end of the SCRIPTS_FOLDER path, and removed the backslash  from the FILE  name begining.

                var SCRIPTS_FOLDER =  "/z/ANIMATION/Max_Renders/FaceLevels/ActionsScripts/";
                var Script1 = File(SCRIPTS_FOLDER + "Script1.jsx");
                var Script2 = File(SCRIPTS_FOLDER + "Script2.jsx");
                var Script3 = File(SCRIPTS_FOLDER + "Script3.jsx");
                $.evalFile (Script1);
                $.evalFile (Script2);
                $.evalFile (Script3);

                 

                 

                Thanks allot!

                 

                 

                Jeff