Thread View: adobe.scripting.indesign
10 messages
10 total messages
Started by Malcolm Wooden
Thu, 19 Mar 2009 12:30
AppleScript do script to run a JavaScript
Author: Malcolm Wooden
Date: Thu, 19 Mar 2009 12:30
Date: Thu, 19 Mar 2009 12:30
9 lines
1013 bytes
1013 bytes
I have a mac program that uses an AS do script to run a JavaScript. However, although the AS starts ID it never gets to trigger the JavaScript which is there to build a page. My AS do script is like this:
on run {aScriptPath}
tell application "Adobe InDesign CS3"
do script alias aScriptPath language javascript
end tell
end run
Why does the JScript not run?
Re: AppleScript do script to run a JavaScript
Author: Kasyan_Servetsky
Date: Thu, 19 Mar 2009 15:16
Date: Thu, 19 Mar 2009 15:16
8 lines
911 bytes
911 bytes
There's probably a problem with aScriptPath. What is its value? This script works for me: set aScriptPath to "Applications:Adobe InDesign CS3:Scripts:Scripts Panel:myScript.jsx" tell application "Adobe InDesign CS3" do script alias aScriptPath language javascript end tell
Re: AppleScript do script to run a JavaScript
Author: Malcolm Wooden
Date: Thu, 19 Mar 2009 15:50
Date: Thu, 19 Mar 2009 15:50
1 lines
916 bytes
916 bytes
The JavaScript is not in the "Applications:Adobe InDesign CS3:Scripts:Scripts Panel" directory. It is created in the fly by my mac program. Does the JavaScript have to be inside this directory for it to run on a Mac? This doen't seem to be the case for Windows.
Re: AppleScript do script to run a JavaScript
Author: Dave_Saunders
Date: Thu, 19 Mar 2009 16:10
Date: Thu, 19 Mar 2009 16:10
7 lines
905 bytes
905 bytes
No, it can be anywhere. If you're creating it on the fly, you could pass the code as a string rather than saving it to a file and using the file reference. Could it be that the issue is that the alias is not being recognized as a file? Try an explicit File reference. Dave
Re: AppleScript do script to run a JavaScript
Author: Kasyan_Servetsky
Date: Thu, 19 Mar 2009 16:12
Date: Thu, 19 Mar 2009 16:12
23 lines
1361 bytes
1361 bytes
Does the JavaScript have to be inside this directory for it to run on
a Mac?
No. You can just copy js code from ESTK and assign it to the variable in script editor, placing it inside double quotes. e.g.
set myJsScript to "target indesign
var myDoc = app.activeDocument;
...
...
// end of JS code "
But be sure to use single quotes inside JS then.
e.g. var myString = 'Blah-blah-blah';
not var myString = "Blah-blah-blah";
You can even send and – if my memory serves me right – receive back parameters (aka arguments). If you are interested I can post an example or send you a script that uses this functionality.
Kasyan
Re: AppleScript do script to run a JavaScript
Author: Malcolm Wooden
Date: Thu, 19 Mar 2009 16:40
Date: Thu, 19 Mar 2009 16:40
5 lines
825 bytes
825 bytes
Kasyan Thanks for the info. I think I may have not been defining the path correctly in my Mac program because the JavaScript file is not being written in the location I expect it to be. I'll look at it again. Malcolm
Re: AppleScript do script to run a JavaScript
Author: Malcolm Wooden
Date: Fri, 20 Mar 2009 14:29
Date: Fri, 20 Mar 2009 14:29
11 lines
1075 bytes
1075 bytes
My ApplsScript looks like this: set aScriptPath to "HD:Applications:Adobe InDesign CS3:Scripts:Scripts Panel:MyJScript.jsx" tell application "Adobe InDesign CS3" do script alias aScriptPath language javascript end tell but when I run it, it errors saying: Adobe InDesign CS3 got an error: Expected: ; However if I run MyJScript.jsx from the ExtendScript Toolkit it will work. Any idea whay AppleScript doesn't like the script?
Re: AppleScript do script to run a JavaScript
Author: Kasyan_Servetsky
Date: Fri, 20 Mar 2009 14:53
Date: Fri, 20 Mar 2009 14:53
6 lines
773 bytes
773 bytes
First of all, I would check if the path of js-file is correct.
e.g.
set mypath to choose file
Data:Applications:Adobe InDesign CS3:Scripts:Scripts Panel:myAlert.jsx
Re: AppleScript do script to run a JavaScript
Author: Dave_Saunders
Date: Fri, 20 Mar 2009 16:21
Date: Fri, 20 Mar 2009 16:21
3 lines
794 bytes
794 bytes
That "Expected: ;" error almost certainly means that JavaScript is trying to execute what you passed as though it were a string rather than a File reference. Dave
Re: AppleScript do script to run a JavaScript
Author: Shane_Stanley
Date: Fri, 20 Mar 2009 22:03
Date: Fri, 20 Mar 2009 22:03
17 lines
1727 bytes
1727 bytes
On 21/3/09 1:29 AM, "Malcolm Wooden" <member@adobeforums.com> wrote: > Adobe InDesign CS3 got an error: Expected: ; You'll get that error if your path is incorrect. Try it this way and you'll find out: set aScriptPath to alias "HD:Applications:Adobe InDesign CS3:Scripts:Scripts Panel:MyJScript.jsx" tell application "Adobe InDesign CS3" do script aScriptPath language javascript end tell -- Shane Stanley <sstanley@myriad-com.com.au> AppleScript Pro Sessions <http://scriptingmatters.com/aspro>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads