• 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: AppleScript to JavaScript and back
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript to JavaScript and back


  • Subject: Re: AppleScript to JavaScript and back
  • From: Stan Cleveland <email@hidden>
  • Date: Fri, 01 Aug 2008 13:34:19 -0700
  • Thread-topic: AppleScript to JavaScript and back

On 8/1/08 8:54 AM, "Oakley Masten" wrote:

> Ok I feel pretty dumb here so Help!
>
> Trying to use Javascript listener to do things with PhotoShop CS2.
> We want to do several things that JavaScript might help.
>
> I recorded a javascript and ask a friend who knows Javascript to help.
>
> We can't figure out how to pass the path and file name to save the image in
> from AppleScript to Javascript.
>
> Where do I start?
>
> Does the path have to be POSIX or can I use HFS?
> If POSIX do I format it with applescript and then pass
> and if so what is the exact format?
>
> Any help would be greatly appreciated

Hi Oakley,

Here is a very brief intro using this demo snippet of Javascript:

   desc3.putPath( id30, new File( "/Users/omasten/Desktop" ) );

The general steps to make listener-recorded Javascript usable in AppleScript
are:

1. Paste the Javascript code into an AS editor window and put quote marks
around it.

   "desc3.putPath( id30, new File( "/Users/omasten/Desktop" ) );"

2. Escape all quote marks within the Javascript with a backslash (\)

   "desc3.putPath( id30, new File( \"/Users/omasten/Desktop\" ) );"

3. Surround the quoted Javascript with 'tell' and 'do javascript' commands.

   tell application "Adobe Photoshop CS2"
   do javascript "desc3.putPath( id30, new File( \"/Users/omasten/Desktop\"
) );"
   end tell

4. Replace hard-coded paths and settings values in the Javascript with
   variables. (You'll need to carefully study the Javascript to identify
   all of these.) Remember that the Javascript is a string, so inserting
   a variable involves splitting the string and concatenating the
   variable between the string segments. Yes, you must use POSIX paths.

   set savePath to POSIX path of (path to desktop) as text
   tell application "Adobe Photoshop CS3"
   do javascript "desc3.putPath( id30, new File( \"" & savePath & "\" ) );"
   end tell

Hope that gives you enough information to get things going!

Stan C.


 _______________________________________________
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/archives/applescript-users

This email sent to email@hidden

References: 
 >AppleScript to JavaScript and back (From: Oakley Masten <email@hidden>)

  • Prev by Date: Re: Alias Files
  • Next by Date: Re: Alias Files
  • Previous by thread: AppleScript to JavaScript and back
  • Next by thread: Re: AppleScript to JavaScript and back
  • Index(es):
    • Date
    • Thread