CS4 do javascript from AppleScript

Hi all,
Consider this AppleScript snippet:
tell application "Adobe Illustrator"
do javascript myFile with arguments {"one", "two"}
end tell
The file "myFile" is executed OK, but how does myFile (a JavaScript script) get the arguments passed in from AppleScript? I don't see this documented anywhere.
Thanks,
Chuck

Since nobody answered this:
In your Javascript, you will find an arguments array containing the arguments you passed from Applescript or VBscript
So, using your example, if you added this line to your JSX file:
alert(arguments[0]);
You would get an alert saying "one" when you ran your Applescript.

Similar Messages

  • How to run ps cs4 js script from applescript

    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

    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

  • [AS & JS] [CS4] Execute javascript from actionscript

    Hi,
    I've written a folder action in Actionscript to open a Indesign file. I would like to execute a javascript that a wrote before. Is it possible to launch a javascript from within a actionscript? Does the actionscript wait to continue until the javascript is completely executed?
    Thanx
    John

    Scott,
    I have no idea how I got this new OTN Id? Tell me what you know!
    I signed on using what I believe is my regular Email Address, but I am no longer attached to the old OTN Id. And I no longer have the gold medal next to my name. Isn't that sad :(
    I really ticks me that we are still (after how many years with Oracle) unable to change our Email Address and keep the same account. What is that with Oracle? Can't anyone teach those people good design (like don't use an externally supplied key as the internal identifier for your customer). I recently sold my Web Domain, and so my Email Address will soon change. The new owner is allowing me to keep my Email Address until Feb 2008.

  • Call JavaScript from AppleScript using InDesign CS2

    Can this be done?
    The following script:
    tell application "Adobe InDesign CS2"
    tell active document
    do script "var thisNumber = 5;" language javascript
    end tell
    end tell
    results in the error:
    tell application "Adobe InDesign CS2"
    do script "var thisNumber = 5;" language javascript
    "Adobe InDesign CS2 got an error: \"var thisNumber = 5;\" doesnt understand the do script message."
    Why doesn't this work and what can I do to fix it?
    William

    On 4/12/08 5:41 AM, "Olav Kvern" <[email protected]> wrote:<br /><br />> These sorts of things are hard to see in AppleScript, because the dictionary<br />> browser(s) don't group methods with their parent objects. Sal Soghoian at<br />> Apple has long said that this needs fixing.<br /><br />And in fact it has been fixed -- it just needs app developers to write their<br />dictionaries appropriately. For a good example, have a look at the<br />dictionary of Script Debugger 4.5 -- you'll see classes listed with<br />elements, properties, and "Responds to". And none of that truncation ID's<br />dictionary is full of.<br /><br />-- <br />Shane Stanley <[email protected]><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>

  • How can I add javascript text fields to Acrobat pages from Applescript please?

    I have a real need to add text fields to Acrobat document pages from Applescript. I can't access the Headers and Footers from Applescript in Acrobat XI. I can set watermarks using the following script, but cannot for the life of me work out how to add text fields. Any advice please?
    Regards
    set TempAttachmentName to "(20140717121212Z)"
    set PreserveFileName to "This is a test"
    set bypass to false
    tell application "Adobe Acrobat Pro"
      activate
      set CountOfPages to count of pages
      repeat with PageCounter from 1 to CountOfPages
      tell application "System Events" to tell process "AdobeAcrobat"
      try
      click menu item "Page..." of menu 1 of menu item "Go To" of menu 1 of menu bar item "View" of menu bar 1
      tell current application to delay 0.1
      keystroke PageCounter as text
      tell current application to delay 0.1
      keystroke return
      if not bypass then
      my ADDHeaderFooter(TempAttachmentName, PreserveFileName & " " & CountOfPages, PageCounter)
      end if
      end try
      end tell
      end repeat
    end tell
    on ADDHeaderFooter(The_String1, The_String2, currentPage)
      tell application "Adobe Acrobat Pro"
      activate
      set myDocument to document 1
      tell myDocument
      tell page currentPage
      set cbox to crop box
      set item 2 of cbox to (item 2 of cbox) + 44
      set item 4 of cbox to (item 4 of cbox) - 44
      set media box to cbox
      set crop box to cbox
      set theResult1 to my Add_WaterMarkText(The_String1, "IDAutomationHC39M", 12, 1, 1, 1, 0, 3, 10, 3, 0)
      do script theResult1
      set theResult2 to my Add_WaterMarkText(The_String2, "Times", 16, 1, 1, 1, 0, 4, 10, -6, 0)
      do script theResult2
      end tell
      end tell
      end tell
    end ADDHeaderFooter
    on Add_WaterMarkText(cText, cFont, nFontSize, nS, nE, nTA, nHA, nVA, nHV, nVV, nR)
      set Params to "cText: '" & cText & "'," & return
      set Params to Params & "cFont: '" & cFont & "'," & return
      set Params to Params & "nFontSize: '" & nFontSize & "'," & return
      if class of nS is integer then set Params to Params & "nStart: " & (nS - 1) & "," & return
      if class of nE is integer then set Params to Params & "nEnd: " & (nE - 1) & "," & return
      -- 0 = left, 1 = centre, 2 = right
      if class of nHA is integer then set Params to Params & "nHorizAlign: " & nHA & "," & return
      -- 3 = top, 4 = bottom
      if class of nVA is integer then set Params to Params & "nVertAlign: " & nVA & "," & return
      -- offset in points
      if class of nHV is integer then set Params to Params & "nHorizValue: " & nHV & "," & return
      -- offset in points
      if class of nVV is integer then set Params to Params & "nVertValue: " & nVV & "," & return
      if class of nR is integer then set Params to Params & "nRotation: " & nR & "," & return
      set javascript to "this.addWatermarkFromText({" & Params & "});"
      return javascript
    end Add_WaterMarkText

    G'day
    Unfortunately I don't have the API. My Adobe Reader installation updating to version XI failed, and subsequent attempts to fall back on the X version are blocked by the partial install of XI. Damn Adobe stuff.
    Could someone please post the relevant part of the API to give me some pointers, please.
    I ha mucked about with some information I found on the Web, and come up with the following, which fails because I can't work out how to address the current document with the variable myDoc.
    Regards, Brian
    set Params to Params & "var myDoc = this;" & return
    set TempAttachmentName to "(20140717121212Z)"
    set PreserveFileName to "This is a test"
    set bypass to false
    tell application "Adobe Acrobat Pro"
      activate
      set CountOfPages to count of pages
      repeat with PageCounter from 1 to 1 # CountOfPages
      tell application "System Events" to tell process "AdobeAcrobat"
      try
      click menu item "Page..." of menu 1 of menu item "Go To" of menu 1 of menu bar item "View" of menu bar 1
      tell current application to delay 0.1
      keystroke PageCounter as text
      tell current application to delay 0.1
      keystroke return
      if not bypass then
      my ADDHeaderFooter(TempAttachmentName, PreserveFileName & " " & CountOfPages, PageCounter)
      end if
      end try
      end tell
      end repeat
    end tell
    on ADDHeaderFooter(The_String1, The_String2, currentPage)
      tell application "Adobe Acrobat Pro"
      activate
      set myDoc to document 1
      tell myDoc
      tell page currentPage
      set cbox to crop box
      set item 2 of cbox to (item 2 of cbox) + 44
      set item 4 of cbox to (item 4 of cbox) - 44
      set media box to cbox
      set crop box to cbox
      set theResult1 to my Add_WaterMarkText(The_String1, "IDAutomationHC39M", 12, 1, 1, 1, 0, 3, 10, 3, 0, myDoc)
      do script theResult1
      set theResult2 to my Add_WaterMarkText(The_String2, "Times", 16, 1, 1, 1, 0, 4, 10, -6, 0, myDoc)
      do script theResult2
      end tell
      end tell
      end tell
    end ADDHeaderFooter
    on Add_WaterMarkText(cText, cFont, nFontSize, nS, nE, nTA, nHA, nVA, nHV, nVV, nR, myDoc2)
      #set Params to "var myDoc = app.newDoc();" & return
      set Params to ""
      set Params to Params & "var myDoc = this;" & return
      set Params to Params & "var inch = 72;" & return
      set Params to Params & "var Bbox = this.getPageBox(" & "\"Crop\"" & ");" & return
      set Params to Params & "var f = myDoc.addField(" & "\"Text1\"" & ", " & "\"" & cText & "\"" & ", 0, [72, Bbox[1]-inch, Bbox[2]-2*inch, Bbox[1]-2*inch ] );" & return
      set Params to Params & "f.strokecolor = color.black;" & return
      set Params to Params & "f.richText = true;" & return
      set javascript to Params
      return javascript
    end Add_WaterMarkText

  • How to call javascript using applescript in InDesign cs2 Mac

    Hi,
    I need to integrate javascript with my apple script??? how to use it???please help me...i need it immediately..........

    Hi Andrew,
    Here is an example for you – a snippet from my script:
    global myBridgeLabel
    -- function that runs on clicking the button in adobe script studio project
    on clicked theObject
    if name of theObject is "b1" then
    set processName to "Started working"
    set myBridgeLabel to "Red"
    set myLabel to 1
    else if name of theObject is "b2" then
    set processName to "Started doing this"
    set myBridgeLabel to "Green"
    set myLabel to 2
    else if name of theObject is "b3" then
    set processName to "Started doing that"
    set myBridgeLabel to "Yellow"
    set myLabel to 3
    else if name of theObject is "b4" then
    set processName to "Finished doing this"
    set myBridgeLabel to "Blue"
    set myLabel to 4
    else if name of theObject is "b5" then
    set processName to "Finished doing that"
    set myBridgeLabel to "Purple"
    set myLabel to 5
    end if
    tell application "Adobe InDesign CS2"
    set mydocument to active document
    set myDocumentPath to full name of mydocument
    set workerName to "Kasyan"
    tell metadata preferences of mydocument
    set theDate to current date
    set myWeekday to weekday of theDate as string
    set myDenNedeli to my convertWeekday(myWeekday)
    set myRecord to (processName & " – " & workerName & " – ") & myDenNedeli & " " & text 1 thru -4 of time string of theDate & " \r"
    set myHistory to get property namespace "http://ns.adobe.com/photoshop/1.0/" path "History"
    set property namespace "http://ns.adobe.com/photoshop/1.0/" path "History" value myHistory & myRecord
    end tell
    set myJavaScript to "var myLabel =\"" & myBridgeLabel & "\"; app.activate(); var bt = new BridgeTalk; bt.target = \"bridge\"; myScript = 'app.displayDialogs = \"none\"; var t = new Thumbnail (File (\"" & myDocumentPath & "\")); var mdata = t.metadata; mdata.namespace = \"http://ns.adobe.com/xap/1.0/\"; mdata.Label = \"' + myLabel + '\";'; bt.body = myScript; bt.send();"
    do script myJavaScript language javascript
    In this javascript I use pares of single and double quotes.
    The main java script – myJavaScript – (inside double quotes) contains another java script – myScript – (inside single quotes) which runs in Bridge via BridgeTalk.
    I also put variables from AppleScript into JavaScript by using two pares of double quotes – the outside pare I escape with slashes:
    set myBridgeLabel to "Red" -- a variable I defined in AppleScript
    set myJavaScript to "var myLabel =\"" & myBridgeLabel & "\"; app.activate();
    -- the contents of myBridgeLabel variable now becomes part of the JavaScript
    Kasyan

  • Pass arguments to javascript from plug in...

    Hi,
    I m using InDesign CS3 on MAC OS...
    I have a plugin calling a javascript. I need to pass a string value from the plug in to the script...
    I found that there is a parameter in the method RunFile in IScriptRunner.h for this purpose... But i don kno how to use this...
    virtual ErrorCode    RunFile(const IDFile& idFile, IScriptEventData* data,  bool16 showErrorAlert = kTrue, bool16 invokeDebugger = kFalse) = 0;
    where,
    @param data is used to pass arguments and return the result IN/OUT
    What does this  IScriptEventData* data carry???
    How to pass a string value as argument to javascript from plugin code and how to retrieve and use it there...
    Is there any sample code for this?
    Someone pls guide me...
    Thank you.

    Are there other command line options with extendscript, like compile to jsxbin etc.. Where is this documented?
    UDevp wrote:
    I used the below command to run script from command prompt, I'm able to run the script but not able to pass arguments to the script.
       "C:\Program Files\Adobe\Adobe Utilities\ExtendScript Toolkit CS4\ExtendScript Toolkit.exe" -run "C:\Program Files\Adobe\Adobe InDesign CS4\Scripts\test.jsx"
    Any suggestion would be helpful..
    It may be possible to edit prefs file with command line and to check file in script.

  • How can I delete all the files in the Adobe CS4 Master Collection from my machine?

    How can I delete all the files in the Adobe CS4 Master Collection from my machine. I have tried Control Panel but it will not do anything, there are no error messages, it is like as if it is ignoring my instruction. Why should it be so difficult to delete programs one does not want. Any ideas please.

    Moved from Cloud forum to Downloading, Installing forum
    Try running the Adobe Cleaner Tool
    http://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html

  • How to go from AppleScript 1.0 to 1.9 or higher?

    Maybe this is a stupid question, but I wonder how I could move from AppleScript 1.0 to 1.9 or higher. I recently downloaded a programme that requires at least 1.9. I then checked my AppleScript version that was installed as part of the Tiger installation, and it was 1.0. According to Apple's support pages it should have been of the late versions. Unfortunately after version 1.8.3 Apple did not provide any download for updating AppleScript (as far as I could find it in this jungle of support pages).
    So any hint how to update AppleScript would be great.
    Thanks and best,
    nbo
    Powerbook G4 17"   Mac OS X (10.4.7)  

    There's no way you're running AppleScript 1.0.
    AppleScript 1.10 was released with Tiger (Mac OS X 10.4). Version 1.0 dates back many years (certainly pre-Mac OS X).
    What's more likely to be the problem is the app you're running is incorrectly checking the version number of AppleScript, not expecting the 1.x number to be more than 1 digit. It's explained a little more in the AppleScript Release Notes, specifically:
    Scripts that compare AppleScript version numbers using string comparisons will need to be changed in order to work correctly with the new AppleScript version number. A considering numeric strings statement must be added before the string comparison so that the string “1.10” will be greater than the string “1.9.3”.
    Scripts that compare version numbers by coercing the version class to a real number and then doing numeric comparisons will need to be changed. The coercion from version to real has been changed to allow the second and third parts of the version number to be 0..15 instead of 0..9. As a result, the version 1.2.3 will now coerce to the real number 1.0203. Previously, it would coerce to the real number 1.23.
    If you have the source for the script you should update its version number checking to be compatible with the current standard. If you don't have it you'll need to contact the developer and get them to update it

  • Problem invoking Javascript from applet

    Hi,
    I have a hidden iframe in my JSP. While submitting the form within the JSP, I set the target of the response page as the iframe and disable all the form elements in the JSP . The response page contains an applet that pops up a window(a JFrame). On pressing the close button of the applet's frame, I invoke a Javascript method in the JSP. This javascript method enables all the components on the JSP.
    Now the issue is that, when I press the close button, the browser just hangs... This doesn't happen on all the browsers.. It works with Opera. In IE it doesn't work all the time. Some times IE just hangs... Any idea what the issue could be?? Pls let me know if the problem is not clear..
    Thanks in advance..
    regards,
    Anand

    Funny I've just posted something about this on another thread.
    http://forum.java.sun.com/thread.jsp?forum=54&thread=157547
    You can apparently call methods on your applets from javascript.
    http://developer.netscape.com/docs/manuals/communicator/jsguide4/livecon.htm#1007749
    I know that most of the LiveConnect package works in NS4, NS6, IE4 and IE5, but I have always called out to JavaScript from Java not the other way around so I cannot vouch for this in IE.

  • How to remove javascript from a form?

    Because some users have javascript disabled in their Acrobat readers I’d like to remove all javascript from a pdf-form I have so that the users with js disable don’t get the dialog every time opening a file. As far as I know there’s no need for javascript on the page. How do I disable or remove js from a pdf-form in Adobe Livecycle Designer ES 8.2 ? Thanks!

    Thanks Paul! I had not noticed that there was more to the script editor than met the eye (the resize thing) Here is a picture of what I found.
    I followed your instructions and deleted the lines with line numbers. Now when I saved and re-opened the document my “Events with Scripts” view is completely empty. Still when I open the document in Reader it says “This document contains JavaScripts. Do you want to enable JavaScripts from now on? The document may not behave correctly if they’re disabled”.
    Any ideas what to do? When I select “Show all events” there’s a lot of lines with (JavaScript, client) after them.. could this have something to do with it?
    - Janne

  • Webkit. How to connect external javascript from dir C:

    I can't execute javascript from dir C:
    I have some html, that I load in Webkit with loadContent(). In that html invoked function test(). Function contains in a separate javascript file.
    <head>     
    <script language='javascript' type='text/javascript' src="file:///C:/temp/test.js"></script>
    <script>
         function getText() { var val = document.getElementById('text_area').value;
              prompt('getText', "val");
    </script>          
    </head>
    <body>
           <textarea id='text_area' name='text_area' style="width:100%; height:100%"></textarea>     
           <script> test(); </script>
    </body>External javascript (test.js)
    function test() {
            alert('It works!');
         getText();           
    }External js doesn't work. PromptHandler (AlertHandler) doesn't catch anything. If I use wEngine.executeScript('test'), appear error: netscape.javascript.JSException: ReferenceError: Can't find variable: getText.
    But that code works on any other browsers.

    Thank you for the problem report!
    This looks like a bug in WebView. A Jira issue has been filed to track this: http://javafx-jira.kenai.com/browse/RT-17330. Note that the issue may end up classified as not-a-bug because the ability to run local scripts from dynamic contents may be considered a security hole.
    As a workaround, try saving your HTML into a temporary file and load it using WebEngine.load(). It should work as in any other browser. Another option is to include all necessary code in the HTML document loaded with WebEngine.loadContent(), but I gather that is undesirable in your case.
    Edited by: 890759 on Oct 11, 2011 5:19 AM
    Edited by: 890759 on Oct 11, 2011 5:21 AM

  • Calling Javascript from ABAP webdynpro application

    Hai All,
    I want to call a Javascript from ABAP-Webdynpro application. If anyone has done this. Please let me know.
    Thanks & Regards,
    H.K.Hayath Basha.

    go to window
    create suspend outbound plug and resume inbound type
    when create an outbound plug of Suspend type a parameter Url is automatically created,
    fire the outbuond plug with the Url to a BSP page where you have JavaScript.
    and fromt he BSP navigate back to WDA again which you can do using by reading the url parameter sap-wd-resumeurl, which contains the WDA URL
    Abhi

  • Calling javascript from a button

    Good morning everyone!
    I need to add a message box that asks the user a confirmation to delete information. So I want my delete button to call the javascript necessary to confirm the delete and then delete.
    My problem is in calling the javascript. I'm able to do so by using an image for my button and in the image attributes add:
    onclick="javascript:confirmDelete('Are you sure you to delete?');"
    This works perfectly, except for one thing: I don't want to use an image for the button. It doesn't fit with the rest of the application.
    I know it can work, because Oracle is using it on this page:
    http://apex.oracle.com/pls/otn/f?p=37719:8:3069181226556730::NO:::
    So how can I call my javascript from an ordinary button?

    I have a related question:
    How can I access the BROWSER_LANGUAGE in javascript? With my method of calling javascript, I didn't find a good way to pass variables to the function that I call.

  • Trigger .jsx (Javascript) through Applescript

    I have .jsx (javascript) for InDesign CS5. I am trying to automate in a batch mode. I would like to know how to trigger that Javascript through applescript. It would be much appreciate if any one help me on this regard.
    ~John

    I have .jsx (javascript) for InDesign CS5. I am trying to automate in a batch mode. I would like to know how to trigger that Javascript through applescript. It would be much appreciate if any one help me on this regard.
    ~John

Maybe you are looking for

  • Can print PS file but not make PDF

    Printing to a PostScript printer with a customized PostScript driver in WordPerfect 5.1 for DOS is what we do every day, but when we print the same job to a PS file we can't make a PDF in Adobe Acrobat Pro 9.4. What can we do to make a PDF? Here is t

  • IPFilter not functioning

    I've just completed setting up ipfilter on a new Solaris 10 box. I followed all the steps in previous post. Everything looked good even ipfstatus showed everything as enabled and working. Off hand I then tried to connect from a blocked IP to this hos

  • Audition won't play!

    I think its related to upgrading to Mountain Lion on mac, but very recently at least, Audition now refuses to play. It launches ok, loads a file ok, but when I hit space bar or play button, it looks like it should be playing, but its just stopped. Ha

  • Quad G5 Logic Pro Users

    I've been following this forum for a few weeks, and I've seen several users demanding better optimization for Quad G5. I wonder what they think needs improvement specifically for the Quad? I just got my Quad 2.5 G5 a couple days ago. I've installed L

  • Upgraded IOS5 and Cloud,  can not find Purchases books

    After upgrading all systems I lost over 10 books (Apple) and one Audiobook?