Converting Simple Indesign AppleScript to Javascript

Hi,
I have been using as imple Indesign AppleScript but need to convert it to javascript and have no prior experience.  I've been reading the Adobe pdf about scripting and it is great as it shows the differences between the 3 (as, js, vb) but I'm still having trouble figuring out how this would conver.  Would anyone be able to show me the converted result?
AppleScript:
tell application "Adobe InDesign CS5.5"
     tell every document
          set visible of layer "Interactive - Web" to true
          set visible of layer "Interactive - Print" to false
     end tell
end tell
Javascript:
var myDocuments = app.documents.everyItem(); // something like this?
It hides/shows the visibility of 2 specific layers for all opened documents.  I pretty much need to hide/show 2 specific layers ina  book and this should/can accomplish that.
Thanks for any help!

This should work:
var documentsArray = app.documents.everyItem().getElements();
for (var i = 0; i < documentsArray.length; i++) {
          var document = documentsArray[i];
          var layers = document.layers;
          layers.itemByName("Interactive - Web").visible = true;
          layers.itemByName("Interactive - Print").visible = false;
Also, it might be possible to do this without using "getElements" which "resolves the object specifier", eliminating the need for the "for" loop. Something like this:
app.documents.everyItem().layers.itemByName("Interactive - Web").visible = true;
app.documents.everyItem().layers.itemByName("Interactive - Print").visible = false;

Similar Messages

  • Converting simple AppleScript to JavaScript

    Hello to all,
    I need to convert a simple AppleScript to JavaScript, but as I don't know one bit about JavaScript, is there anyone willing to help me out ?
    Here is the AppleScript:
    tell application "Adobe Photoshop CS5"
         activate
              set display dialogs to never
              set thisdoc to current document
              tell thisdoc
                        resize image resolution 300 resample method none
              end tell
    end tell
    Very simple script to resize some low-res pictures without touching final resolution.
    Thanks !

    This will change the resolution only..
    app.displayDialogs = DialogModes.NO;
    activeDocument.resizeImage(undefined, undefined, 300, ResampleMethod.NONE);

  • Applescript to Javascript

    I have an Applescript that I need to convert it into  Javascript.
    To create Indesign instancs in applescript i use
    tell application "Adobe InDesign CS5" statement
    How create Indesign instancs in JavaScript
    or what is equivelent statement of ( tell application "Adobe InDesign CS5" ) in Java Script
    Using COM I create Indesign Instance like
    #include "indesign.h"
    INDESIGN::_Application oApplication;   
    if(oApplication.CreateDispatch(L"InDesign.Application") ==0)
        AfxMessageBox(L"Dispatch is not created");
    How create Indesign instance using java Script ?
    Thanks.

    Thanks CarlosCanto for reply
    I am a new developer and want to create indesign application.
    First I explane you, What i want to do?
    I want to create an Indesign application for both mac and window os.
    First I use COM and crate indesign application
    #include "indesign.h"
    INDESIGN::_Application oApplication;   
    if(oApplication.CreateDispatch(L"InDesign.Application") ==0)
         // Dispatch is not created;
    But COM is not supported on mac so i want to use JavaScript
    I am using Qt to develop my application and i want to create a java script .
    When I run my JavaScript on window  then Indesign application should start .
    In my post I write about ExtendScript ToolKit 3.6, but i do not want to use this tool.
    For example on mac in Apple Script when i run my apple script
    tell application "Adobe InDesign CS5.5"
    set myDocument to make document with properties
    end tell
    in apple script editor which is inbuild with mac, Indesign Application start(create) sucessfully.
    I want to use javaScript editor inbuild with window.
    Like in applescript there is no need to put the script in  /Users/<username>/Library/Preferences
    /Adobe InDesign/Version 7.5/<locale>/Scripts
    Simply when i run apple script application create. I want to such using java script.
    I do not want to put my script C:\Documents and Settings\<username>\Application Data
    \Adobe\InDesign\Version 7.0\<locale>\Scripts      
    to start indesign application
    http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/indesign/cs55-docs/In DesignScripting/InDesign-ScriptingTutorial.pdf
    Establish communication with the InDesign application object:
    AppleScript :   tell application "Adobe InDesign CS5"
    VBScript     :    Set myInDesign = CreateObject("InDesign.Application")
    JavaScript   :    Refer to the application as app.
    plz give a simple java script (.js) file example which create Indesign Application (instance) , when i run my java script in any java script editor, No need to put script /Users/<username>/Library/Preferences/Adobe InDesign/Version 7.5/<locale>/Scripts and run script after run indesign.
    Like in VB to create indesign object we use CreateObject("InDesign.Application"). In javascript how create object of InDesign Application.
    Thanks

  • Uploading a File with AppleScript via JavaScript

    Hi everybody,
    being new to AppleScripting and JavaScripting I'm faced with the following problem:
    Is it possible to make AppleScript to input the path for a file to be uploaded via JavaScript? If yes, what should be the correct Path Format and how to wrap it up the JavaScript action into AppleScript? I've tried a few comands but to no success.
    On the webpage in question, there's a "Choose" button, that is defined as follows:
    <input type=​"file" class=​"gwt-FileUpload" name=​"swfFile">​
    I've been trying to use the following syntax:
    do JavaScript "document.getElementsByName('swfFile')[0].value('Macintosh HD:Users:myaccount:Desktop:Scrapbook:!动画.swf')" in document 1
    as well as this one, where the Path is definitelly understood by shellscript:
    do JavaScript "document.getElementsByName('swfFile')[0].value('/Users/myaccount/Desktop/Scrap book/!动画.swf')" in document 1
    The name of the file is (and must remain) in chinese, but for testing purposes I have also tried files with english names, without success.
    Currently I'm using a solution with JavaScript comand:
    do JavaScript "document.getElementsByName('swfFile')[0].click()" in document 1
    to click the finder  window to browse for the file, and manipulating  keystrokes by using System Events to find the right file, but it's not  infallible with a number of files and it's hardly an ellegant sollution.
    Any idea what I'm doing wrong?
    Cheers!

    @twtwtw
    the do JavaScript "document.forms[0].submit()" command didn't work, so I kept the original way of submitting by clicking the button. The submitting part works, but not the input file part.
    That's the code I used
        tell application "Safari"
            do JavaScript "document.getElementById('gwt-uid-13').value='on'" in document 1
            do JavaScript "document.forms[0].elements['swfFile'].value=" & "'" & SWFFilePath & "'" in document 1
            do JavaScript "document.getElementsByClassName('gwt-SubmitButton')[0].click()" in document 1  
            delay 1
        end tell
    with SWFFilePath set as the POSIX path as well as the default file format
    Macintosh HD:Users:myaccount:Desktop:Scrapbook:!动画.swf'
    but it did not work.
    If you've got the time, feel free to upload an .swf. The service is free and the server delats uploaded files after 15 min. (if you don't have any, you may try an empty .txt file instead - it won't get converted, but the point is just to get it into the input box).
    In the meantime, I'll have a look at adayzdone's suggestion. It's not perfect (the downside being that it requires the window to be active, so I can't run the script in the background or with my screensaver & password on), but it's still more reliable than my sollution with navigating arrowkeyes.

  • Just one Quark file to convert to InDesign

    I have just a single, simple 2 page Quark file I need to convert to InDesign.  I don't remember which version of QuarkXpress it was, possible version 6.  My old Mac that ran Quark is not working now, so I cannot check.  But I have a copy of the  file that I need converted to work on InDesign CC.  A company called Markzware has a plug-in that can do the job, but paying $200 for it is too steep for just one file. 
    Is there a cheaper way?  I'd be happy to pay, say, $40 to get this file converted.  Thanks for any help!

    I can open and down save it, then get it into ID for you. I have a few versions of Quark installed.
    I have never gone this route and don't know the quality of conversion, however. Don't have markzware's stuff.
    Gratis. No charge. Zip. Buy me a coffee sometime if we ever see each other.
    Upload it to dropbox.com or your own server and PM me the link. I will be out golfing the remainder of the day and can see how well it goes later this evening.
    Mike

  • How do I convert an InDesign file into a PDF file, it won't let me do it when I 'Save As'. Help??

    I need help with converting an InDesign file into a PDF file.
    I've tried looking into the program and seeing if i can do it, but it is not giving me the option.
    I need to be able to do this for work purposes.
    Please help.

    Try Exporting. There are also number of useful Export PDF presets that come with design.
    What do you want to do with the PDF?

  • I have to reformat my hard drive and reinstall all of my programs. What do I do about Creative Cloud? I also still need access to CS6 (I have a Marksware converter for InDesign to Quark).

    I have to reformat my hard drive and reinstall all of my programs. What do I do about Creative Cloud? I also still need access to CS6 (I have a Marksware converter for InDesign to Quark).
    This is a MacBook Pro 15" (Model number A1286) running Mavericks. Hard drive is fine but system software has been corrupted. I cannot simply restore from Time Machine as it will copy the corrupt system.
    Will I have to find all of my serial numbers before I can launch any of the programs?
    Thanks

    For the Cloud, you log in to your paid Cloud account and download & install the same way you did the first time
    Cloud Getting Started https://helpx.adobe.com/creative-cloud/topics/getting-started.html
    If you have the perpetual license version of CS6 you install from your original media and use your serial number
    If you have the version of CS6 that is installed via the cloud use this link
    http://helpx.adobe.com/creative-cloud/kb/download-previous-versions-creative-applications. html
    -or http://www.adobe.com/downloads/other-downloads.html

  • How to get all images in indesign CS5 with javascript?

    Hi,everybody,
    How to get all images in indesign CS5 with javascript?I want to delete them.
    Anyone can give me some example codes?
    Thanks,
    Bridge

    Hey!
    This will remove all images from your InDesign document:
    var myLinks = app.activeDocument.links.everyItem().parent;
    for(var i = 0; i < myLinks.length; i++)
        myLinks[i].remove();
    Hope that helps.
    tomaxxi
    http://indisnip.wordpress.com/
    http://inditip.wordpress.com/

  • How to place a word document in a TextFrame with InDesign CS2 scripting (JavaScript)?

    I´m newbie with InDesign CS2 Scripting (JavaScript). I need some help to understand the way to place a Word document in an indesign template, using JavaScript(.jsx).
    Thank you for the help,
    Peter

    //PlaceTextFileInFrame.jsx
    //An InDesign CS3 JavaScript
    //Places a text file in a text frame.
    var myDocument = app.documents.add();
    //Set the measurement units to points.
    myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
    myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
    //Create a text frame.
    var myTextFrame = myDocument.pages.item(0).textFrames.add({geometricBounds:myGetBounds(myDocument, myDocument.pages.item(0))});
    //Place a text file in the text frame.
    //Parameters for TextFrame.place():
    //File as File object,
    //[ShowingOptions as Boolean = False]
    //You'll have to fill in your own file path.
    myTextFrame.place(File("/c/test.txt"));
    function myGetBounds(myDocument, myPage){
    var myPageWidth = myDocument.documentPreferences.pageWidth;
    var myPageHeight = myDocument.documentPreferences.pageHeight
    if(myPage.side == PageSideOptions.leftHand){
    var myX2 = myPage.marginPreferences.left;
    var myX1 = myPage.marginPreferences.right;
    else{
    var myX1 = myPage.marginPreferences.left;
    var myX2 = myPage.marginPreferences.right;
    var myY1 = myPage.marginPreferences.top;
    var myX2 = myPageWidth - myX2;
    var myY2 = myPageHeight - myPage.marginPreferences.bottom;
    return [myY1, myX1, myY2, myX2];

  • Why does Acrobat drop i's when converting from InDesign?

    I have Acrobat Professional 9 and InDesign CS4.  Sometimes when converting an InDesign document to PDF, it will drop some i's.  It doesn't drop all i's, just some.  I can go back and do it again and the next time it won't.  This is so frustrating.  Has anyone ever encountered this problem?
    Thanks!

    OK, we're on common ground, that, although  I've thrown two press runs into the garbage, I haven't researched beyond -
    Lower case fi is a ligature; a separate glyph substituted for better spacing and appearance. In ID's preferences, you can toggle to show substituted glyphs. I cannot say if they are good or bad. From the Character Panel you can choose not to use ligatures.
    I do not know if I had a corrupt font or an incompatability between ID and AA. As a workaround I either opened the document on a different system, or turned off ligs.
    Notice how many errors I had in a directory based mostly in Southfield, for financial professionals.
    This problem would be better addressed in the ID forum.

  • Pdf converter to indesign

    hi everybody,
    Is there any free pdf converter to Indesign project? i'm in search of pdf converters to indesign projects but i found some plugins that i must pay for them.
    Thanks in advance.

    If you need them, pay for them.
    The people that develop plugins of this sort spend massive amount of time on them. For anyone stuck with a PDF that needs to be converted it’s well worth the price of the plugin.
    Bob

  • Getting errors while updating links in Indesign document using javascript

    Hi,
    We are updating the links in InDesign document using javascript. After running the script, we are getting the below errors in Adobe InDesign CC debug.
    When closing the document for first time we are getting the below mentioned errors,
    ASSERT 'fRefCount == 0' in c:\development\citius\source\components\database3\revisioneddatabase\SaLRICache.tpp at line 230 failed.
    Erased item list not empty at block delete time
    blockUID = 10486786 not freed
    Internal error: 904 items were leaked!
    After that we are opening the same document for second time, then we are getting the below mentioned errors,
    ASSERT 'ts_DBPubFile->PlacementUIDIsAvailable(uid)' in c:\development\citius\source\components\database3\revisioneddatabase\SaLRIUtils.tpp at line 195 failed.
    DB failed to create UID!
    ASSERT 'this->FindInIDRangeList(fLastCreatedBlockUID) >= 0' in c:\development\citius\source\components\database3\revisioneddatabase\SaLRICache.tpp at line 476 failed.
    ASSERT 'fLastCreatedBlockUID != kInvalidUID && fLastCreatedItemID != 0' in c:\development\citius\source\components\database3\revisioneddatabase\SaLRICache.tpp at line 467 failed.
    ASSERT '(SaLRIUtils<SnapshotID , SnapshotInfo>::ts_DB)->IsValidUID(itemUID)' in ..\..\..\source\components\database3\revisioneddatabase\SnapshotCache.cpp at line 55 failed.
    Please help us to solve this error in InDesign debug.
    Thanks,
    Vimala L

    You're probably better off raising this in the SDK forum.

  • Sechs-Ecken-Objekt mit InDesign CS3-Script / JavaScript ???

    Hallo.
    Können Sie mir evtl.  helfen? Siehe Bild im Anhang.
    Wie kann ich dieses Sechs-Ecken-Objekt (Kontur 1 Pkt nach innen) mit Indesign-Script erstellen ? (InDesign CS3-Script / JavaScript)
    myPolySCHATTEN = myDocument.pages.item(0).polygons.add();   ???
    oder mit
    myPath = myDocument.paths.item(0).add();                                  ???
    Oder... ????
    Freundliche Grüße,
    AndreasRoe aus Germany

    Piece of cake.
    You can either create a default Rectangle or Polygon, and add and move the points around, or -- my preferred way -- add a GraphicLine and add the other points to that path, until you are nearly done. Then set the path type to "Closed", and you are really done.
    For starters, let's create a regular rectangle the hard way:
    var hoehe = 10;
    var breite = 20;
    newrect = app.activeDocument.graphicLines.add ();
    newrect.paths[0].pathPoints[0].anchor = [0,0];
    newrect.paths[0].pathPoints[1].anchor = [0, hoehe];
    newrect.paths[0].pathPoints.add({anchor:[breite,hoehe]});
    newrect.paths[0].pathPoints.add({anchor:[breite,0]});
    newrect.paths[0].pathType = PathType.CLOSED_PATH;
    Run this and experiment with breite / höhe.
    If you look at your drawing, you can see you need an inset value for the chopped off corners. You can also see where to add the new points, when you start counting at top left. That results in this -- notice how breite / höhe are adjusted one by one:
    var hoehe = 50;
    var breite = 100;
    var inset = 4;
    newrect = app.activeDocument.graphicLines.add ();
    newrect.paths[0].pathPoints[0].anchor = [0,0];
    newrect.paths[0].pathPoints[1].anchor = [0, hoehe - inset];
    newrect.paths[0].pathPoints.add({anchor:[inset,hoehe]});
    newrect.paths[0].pathPoints.add({anchor:[breite,hoehe]});
    newrect.paths[0].pathPoints.add({anchor:[breite,inset]});
    newrect.paths[0].pathPoints.add({anchor:[breite-inset,0]});
    newrect.paths[0].pathType = PathType.CLOSED_PATH;

  • Translation AppleScript to JavaScript

    Hi all,
    I need a translation from AppleScript to JavaScript.
    tell application "Adobe Illustrator"
    activate
    do script "Neigen" from "Prepress" without dialogs
    end tell
    Can anybody help?
    Thanks a lot.
    Sabine

    If all you want to do via Applescript is chain several 'Actions' to run in a certain order then just duplicate the action line and change the name strings to those of the other action & action sets like so…
    tell application "Adobe Illustrator"
    activate
    do script "Neigen" from "Prepress" without dialogs
    do script "Action A" from "Set A" without dialogs
    do script "Action B" from "Set B" without dialogs
    end tell
    Both the names strings of the actions & the action sets are case sensitive…

  • Converting old Quark applescript to InDesign - problems

    Hello
    I'm converting an old Quark applescript to InDesign CS3 finally. I'm having a problem with placing, scaling and adjusting images.
    Here's how it works ... a user fills out a Microsoft Word form, which a designer unlocks and pastes into the layout, and then runs the script. The image frames are all labeled, and that's how I'd like to call them.
    Here's a snippet of the Quark portion that I'm having a problem with ...
    set Todayicon to item (offset from list Dayicons of Todayval) of DayIconEPS
    set Todayiconpath to (OPIpath and Todayicon as string)
    set Todayicon to item 1 of Todayiconpath
    set scale of Todayicon to {"65","65"}
    set offset of Todayicon to {"-1p2","0p5"}
    And here's what I'm thinking I need to do in InDesign CS3 ...
    set Todayicon to item (offset from list Dayicons of Todayval) of DayIconEPS
    set Todayiconpath to (OPIpath and Todayicon as string)
    set Todayicon to item 1 of Todayiconpath
    set TodayiconTransformationMatrix to make transformation matrix with properties {horizontal scale factor:0.65, vertical scale factor:0.65, geometric bounds:[-14,-5]
    transform Todayicon in inner coordinates with matrix TodayiconTransformationMatrix
    Unfortunately, the script errors out when it tries to make the transformation matrix, even though I'm following the examples in the Working with Tranformations in Applescript pdf.
    Any ideas? I guess I can put dummy images in the layout and call a "Place" to override the dummy images, which should keep the scale, but it doesn't help me when I need to offset the images sometimes.

    Philip Regan wrote: "The new scripting model with all of its touted advantaged is really poorly executed."
    While I didn't design the scripting model for transformations, and disagree with some of the decisions made in the design, I understand that InDesign's transformations architecture had to be rewritten for CS3. There were too many cases in CS2 where objects could not be returned to their original coordinates after transformation. The scripting implementation pretty much had to go along with the change in the underlying architecture.
    If you'd rather things work the way they worked in CS2, why not use the set of transform "wrappers" that I wrote and included in the transform tutorial? With those functions, you don't really need to worry about the new model.
    Thanks,
    Ole

Maybe you are looking for

  • Firefox aborts its http request silently within 60 seconds

    duplicate of [/questions/1047223] *Summary Firefox aborts its http request within almost 60 seconds(period till timeout varies) and tells nothing to users. This happened with both of Nginx and Apache. *Environment Client browser: Firefox 35.0.1 Clien

  • Is there a way to reverse a region with midi notes?

    i have a two bar loop of some midi notes and want to reverse the region and see what it sounds like.

  • Aperture 3 Library Size

    Does anyone have any idea what the amount of referenced images in an aperture 3 Library should be? Has this changed from Aperture 2? I am trying to get all of my libraries moved over and wonder if the limits have changed and how it affects speed in 6

  • Call a VB EXE from ABAP

    Hi all, I would like to call a Function (with 3 Param) of a given VB-EXE or VB-Script from my ABAP. Is there anyone who can help me ?? Thanks

  • Printing a Picture Frame

    I've inserted pictures and then subsequently framed them in Pages...and when I print this beige background shows up around my frame...how do I get rid of this and make the color flush with my white paper?