• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Call JavaScript from AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Call JavaScript from AppleScript


  • Subject: Re: Call JavaScript from AppleScript
  • From: Stan Cleveland <email@hidden>
  • Date: Thu, 22 Feb 2007 11:50:16 -0800
  • Thread-topic: Call JavaScript from AppleScript

Title: Re: Call JavaScript from AppleScript
On 2/22/07 7:26 AM, Rich Sweeny wrote:

I am having problems calling and passing arguments from a AppleScript file to a _javascript_ file. Would anyone know the proper way of doing this?
**** The applescript file ******
using terms from application "Adobe Photoshop CS2"
      set scriptFile to a reference to file "Users:Shared:bin:AdobeAutomate:ProcessPhotoshopFiles.jsx"
      do _javascript_ scriptFile with arguments {custName, jobNo, linkArtPath}
end using terms from


****  The _javascript_ file called ProcessPhotoshopFiles.jsx *****
var custName;
var jobNo;
var linkArtPath;

// used for testing the script
checkPhotoshopFiles( custName, jobNo, linkArtPath );

// a folder to move files which are out of spec
var outOfSpecFolder = linkArtPath + "/OutOfSpec-Images/";
var vectorArtFolder = linkArtPath + "/VectorArt";

function checkPhotoshopFiles( custName, jobNo, sourcePath ) {
....
}

Pay attention to how you’re passing variables from AppleScript to the Photoshop _javascript_ code. The sample below shows how to pass in data. It uses hard-coded _javascript_ code, but you can extrapolate the same approach to work with a _javascript_ file.

Stan C.

on duplicatePath(pathName, dupName)
    set pathValid to true -- default value
   tell application "Adobe Photoshop CS2"
        activate
       try
           do _javascript_ ("function dupPath(pathName, dupName)
        {
        var pathRef = new ActionReference();
            pathRef.putEnumerated( charIDToTypeID( \"Path\" ), charIDToTypeID( \"Ordn\" ), charIDToTypeID( \"Trgt\" ) );
        var duplicatePath = new ActionDescriptor();
            duplicatePath.putReference( charIDToTypeID( \"null\" ), pathRef );
            duplicatePath.putString( charIDToTypeID( \"Nm  \" ), dupName );
        executeAction( charIDToTypeID( \"Dplc\" ), duplicatePath, DialogModes.NO );
        }
        dupPath( arguments[0] , arguments[1] );") with arguments {pathName, dupName}
        on error number 4251 -- path does not exist
           set pathValid to false
       end try
   end tell
   return pathValid
end duplicatePath
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden

References: 
 >Call JavaScript from AppleScript (From: Rich Sweeny <email@hidden>)

  • Prev by Date: Call JavaScript from AppleScript
  • Next by Date: [admin] Archives link not working.
  • Previous by thread: Call JavaScript from AppleScript
  • Next by thread: changing text color
  • Index(es):
    • Date
    • Thread