DoScript Turducken? [JS] [AS]

Is there another way, in addition to store a string value in a script argument to run a turducken script style?

It works, although very few practical I'm always curious how to do it in one line...

Tell application "Adobe InDesign CS3"

tell the script args
' value name 'my_applescript', 'display alert \"DOSCRIPT TURDUCKEN\.
tell the end
do script "(var my_applescript = app.scriptArgs.getValue(\"my_applescript\");app.doScript((my_applescript)(, ScriptLanguage.applescriptLanguage);" "javascript language

tell the end

If you declare a string value in a statement that has already escaped quotes, it results in the error: incomplete string constant.

~ mike

You must quote your literal applescript, with a level of escapes.

Tell application "Adobe InDesign CS3"

do script "var my_applescript = \"display \\\"DOSCRIPT TURDUCKEN\\\"\";app.doScript(my_applescript, ScriptLanguage.applescriptLanguage); alert' javascript language

end say

Dirk

Tags: InDesign

Similar Questions

  • [jsx] synchronous app.doScript / callback / event?

    Hi all

    I request a node script from inDesign via app.doScript + applescript script, works like a charm. Now, I'm trying to find a way to let inDesign wait the makings of the node end and continue with the returned values:

    var response = app.doScript("tell application \"Terminal\" do script with command \"node\" script.js [...]");
    // wait for async js to finish...
    alert(response);
    

    I'm pretty new to InDesign scripting and was thinking about something like a reminder-version of doScript or event, but found nothing.

    Is this possible?

    Thank you very much!

    see you soon

    I think your solution is to use a flag system. This could be a temp file that your node js would exit when it ends. InDesign script on his side can monitor this file thanks to the inactive events appearance. Then analyze the contents of the files, and remove it later.

  • Remove the dialog box when you run the app.doscript jsxbin file

    I use InDesign CS6 and write a script loop in ExtendScript Toolkit CS6 (Extendscript ScriptUI 6.1.8 4.2.12)

    I use a file jsxbin inside a loop.  After the jsxbin file is a popup alert dialog appaers script, saying: it's done and I have to click on the ok button, before it will allow my script to continue.  I run the file app.doscript jsxbin ("[jsxbin string here]").  I tried to change the level of user interaction to never interact before running the doscript, but this had no effect.  Is it possible to run the userInteractionLevels.NEVER_INTERACT as a parameter in app.doscript?  OR, is there a way to automatically close the popup alert script when it opens.  I'm trying to avoid having to press the OK button several times that the script is running.

    I'm relatively new to scripting in InDesign.  Any advice or assistance would be greatly appreciated.

    Hi callentill1308,

    You're kind of asking for help to hack a jsxbin that isn't yours?

    Well okay, we will try to find a fair solution. First of all, there are good reasons to assume that jsxbin code itself contains instructions forcing userInteractionLevel to INTERACT_WITH_ALL. Something like:

    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
    // ...
    // Process
    // ...
    alert('Done');
    

    In this case, the parameter userInteractionLevel to NEVER_INTERACT in the calling script will have no effect.

    But, if you are sure that the jsxbin script calls the alert() function, a radical way to bypass the message is to rewrite this function itself:

    // inhibits alert()
    $.global.alert = function(){ };
    
    app.doScript( "[jsxbin string here]" );
    

    @+

    Marc

  • Error with doScript

    Work in IND 3 here.

    I try to call a script from an event in a startup script, but I keep running into this error.

    He says that it is exprecting;  on the line where the doscript method is called.

    Here's what I have:

    var scriptPath = new queue (app.fullName);

    had to use app.fullName as it is running of startup scripts

    var sPath = scriptPath.path + "Scripts/Scripts%20Panel/myScript.jsx";

    var runPath = new queue (sPath);

    app.doScript (runPath, ScriptLanguage.javascript);

    Any ideas why I get this error?

    Reply to my message. The above was a simple problem. I was missing a slash at the end of my scripPath variable.

    var sPath = scriptPath.path + "Scripts/Scripts%20Panel/myScript.jsx";

    Should have been

    var scriptPath.path = sPath + "/ Scripts/Scripts%20Panel/myScript.jsx";

  • Something similar to app.doScript in bridge?

    I'm trying to run a script from a button on a palette. app.doScript does not work in Bridge.

    To run a script...

    $.evalFile (File("~/myScript.jsx"));
    
  • [JS CS4/CS5/CS5.5] How to get the return value from Javascript using doScript

    Hi all

    I'm calling javascript from COM (c#) and it works fine. Passing parameters to javascript and playback by using the syntax of the [x] arguments also works very well.

    What I can't seem to get to work is to know how to move something from javascript to the calling COM Summoner, in this case, c#. How and where should I place the return value in javascript?

    Thanks in advance.

    Rachiud

    doScript() evaluates an expression, so just make sure that your Javascript is an expression.

    For instance "(3 + 3)" 6 "

  • Through the program without BridgeTalk doscript?

    If I have a script that is not really something in Indesign or Illustrator but rather the folder and file management and reads an xml file to fill in a lot of variables, it is possible to call a script (using doScript()); that target Indesign or Illustrator and her main script variables or this must be done using BridgeTalk only?

    Just a little dilapidated,

    I have a script that asks the user to a job number, that it proceeds then to find a corresponding with all the job information, xml file creates the necessary files and copies created the illustrator files good that he needs in this folder.  I want to call a script of illustrator we have then open the illustrator file, the layers away strip it does by comparing its contents with the data from the xml file and resave it. Then, open an indesign file, link all images with this new illustrator file and fill out a bunch of tags/variables with data from the xml file and PDF export.

    Currently, I have all these three steps in scripts separated that we manually run every step of the way to the bottom of the line of work, but I would just have pass automatically using a main script.

    It is possible with doscripts() or BridgeTalk inevitable?

    If your scripts are written in JS, BridgeTalk is the best option for you because it is designed for communication between Adobe applications.

    Another option is to translate your scripts to the ACE or VB, in this case, you can address all applications directly. doScript is used for the execution of a script written in another language in InDesign and is very useful to overcome some limitations of JS. For example, the main part of a script written in JS can deal with links in the current document: via BridgeTalk run a Photoshop script that opens, resizes, sharpens,... etc., saved, closed to each image. Then, it updates all the links and exports the document to the pdf file. Finally the script sends the pdf file by e-mail with the request to "Mail" which can not be implemented in JS, so this part is written in AS and triggered by doScript of the script 'hand '.

    BridgeTalk is not as scary as it may seem at first. Here on the forum, you can find many examples of interaction even InDesign with Photoshop, Bridge, Illustrator, and Acrobat.

    I hope this helps.

    Kas

  • doScript runtime with a GUI error

    Hi all

    I am facing a problem, I got a dialog box and several options of Checkbox in that and for every box I have just wan to run a script.

    but it shows an error after clicking on the ok button, the error is

    "Can't manage demand because a modal dialog box or the alert is active.

    Here is my code

    function ps()

    {

    var res =

    "dialog {------}.

    orientation: 'column ', \

    alignChildren: 'left ', \

    img:Image {------}

    size: [130,90].

    }\

    xmlot:Panel\

    {\

    xml:Group {------}

    orientation: 'row ', \

    s:StaticText {text: 'Select for XML Export'} \

    box b: {text: 'Word Out of the Index', alignment: 'left'}, \

    c: box {text: 'Index Out with Page number', alignment: 'left'}, \

    d: box {text: 'XML Out', alignment: 'left'}, \

    }\

    },\

    buttons: group {orientation: 'row', alignment: 'just'------}

    okBtn: button {text: 'OK', properties: {name: 'ok'}}, \

    cancelBtn: button {text: 'Cancel', properties: {name: 'Cancel'}}.

    } \

    }";

    var win = new Window(res,"Utility");

    win.center ();

    (" win.img.icon = File("/InDesign/logo.jpg ");

    win.buttons.okBtn.onClick = function)

    {

    If (App.Documents.Count () > 0)

    {if(win.xmlot.xml.b.value==true)

    {app.doScript (new File("/InDesign/wo.jsx")(, ScriptLanguage.JAVASCRIPT) ;}}

    if(Win.xmlot.Xml.c.Value==true)

    {app.doScript (new File("/InDesign/Generation.jsx")(, ScriptLanguage.JAVASCRIPT) ;}}

    if(Win.xmlot.Xml.d.Value==true)

    {app.doScript (new File("/InDesign/Export.jsx")(, ScriptLanguage.JAVASCRIPT) ;}}

    }

    }

    win.buttons.cancelBtn.onClick = function () {}

    Win.Close (true);

    }

    Win.Show ();

    }

    Hey!

    You must move the function that is executed when you click outside the dialog box.

    --

    tomaxxi

  • doScript Indesign CS5 verdict?

    I read a few posts about using the doScript make a script go faster.

    I also read all the warnings.

    I'm confused as to what I should use.

    FAST_ENTIRE_SCRIPT IS MY SCRIPT OIN 9.8 SECONDS... BUT I HAVE A LOT OF TRY CATCH AND I READ THAT THE 2 DO NOT PLAY WELL TOGETHER (?)

    ENTIRE_SCRIPT ALSO WORKS, BUT ACTUALLY RUNS THE SCRIPT (19.080) SLOWER THAN ANY CALL KEY (11,400).

    A CS5 corrected the problems that were in previous versions?

    Thank you

    Fix. You don't want to use FAST_UNDO if you try/catch in your script.

    This isn't a bug. FAST_UNDO is faster because there is less control. Don't not using try/catch is a concession to this fact...

    Substances

  • doScript

    Hi all

    This is my Code:

    var TemplateFile is File.openDialog ("choose the Template file");.

    var dossier_racine is Folder.selectDialog ("choose the root folder");.


    var copyPasteScript ="";
    copyPasteScript = 'tell application \"Finder\"\r ";
    copyPasteScript += "set dstFlChk to \""+TemplateFile+"\"\r."
    copyPasteScript += "If there is file dstFlChk then\r";
    "copyPasteScript +="double \""+TemplateFile+"\" to \""+Root_Folder+"\"\r ";
    copyPasteScript += 'end if\r;
    copyPasteScript += 'end say'


    app.doScript (copyPasteScript, ScriptLanguage.applescriptLanguage);

    It is not copying the file, I don't know what the problem is.

    I also tried this,

    1 copyPasteScript += ' copy the file (\""+TemplateFile + "------" as string) on file (------"") "+ dossier_racine +"as string);

    2 copyPasteScript += ' copy the file \""+TemplateFile + '-' in folder------'' + dossier_racine + '\' \r';»

    3 copyPasteScript += "duplicate file (\""+TemplateFile+"\ 'as string) to folder (\""+Root_Folder+"as string) \"\r;

    What is the problem, please indicate the exact code

    Thanks in advance

    In fact, my task is to copy the file and paste it into a folder of destination, but the thing is he doesn't have to change the creation date.
    While doing some copy paste in javascript, it modifies the current date to the file. It shouldn't happen in my case.

    It's a little late to meet - two weeks have already passed - but here's a function I wrote to deal with this problem, it works both for Mac and Windows.

    Kasyan

    function MoveFile(myFile, myFolder) {
         if (!myFile instanceof File || !myFolder instanceof Folder || !myFile.exists || !myFolder.exists) return false;
         var myMovedFile = new File(myFolder.absoluteURI + "/" + myFile.name);
         if (File.fs == "Windows")  {
              var myVbScript = 'Set fs = CreateObject("Scripting.FileSystemObject")\r';
              myVbScript +=  'fs.MoveFile "' + myFile.fsName + '", "' + myFolder.fsName + '\\"';
              app.doScript(myVbScript, ScriptLanguage.visualBasic);
         }
         else if (File.fs == "Macintosh") {
              if (myFolder.fsName.match("Desktop") != null) {
                   var myMacFolder = myFolder.fsName.replace(/\//g, ":");
                   var myMacFile = myFile.fsName.replace(/\//g, ":");
                   var myAppleScript = 'tell application "Finder"\r';
                   myAppleScript += 'set myFolder to a reference to folder (name of startup disk & "' + myMacFolder + '")\r';
                   myAppleScript += 'set myFile to a reference to file (name of startup disk & "' + myMacFile + '")\r';
                   myAppleScript += 'tell myFile\r';
                   myAppleScript += 'move to myFolder\r';
                   myAppleScript += 'end tell\r';
                   myAppleScript += 'end tell\r';
              }
              else if (myFolder.fsName.match("Documents") != null) {
                   var myMacFolder = myFolder.fsName.replace(/\//g, ":");
                   var myMacFile = myFile.fsName.replace(/\//g, ":");
                   var myAppleScript = 'tell application "Finder"\r';
                   myAppleScript += 'set myFolder to a reference to folder (name of startup disk & "' + myMacFolder + '")\r';
                   myAppleScript += 'set myFile to a reference to file (name of startup disk & "' + myMacFile + '")\r';
                   myAppleScript += 'tell myFile\r';
                   myAppleScript += 'move to myFolder\r';
                   myAppleScript += 'end tell\r';
                   myAppleScript += 'end tell\r';
              }
              else {
                   var myMacFolder = myFolder.fullName.replace(/\//, "").replace(/\//g, ":");
                   var myMacFile = myFile.fullName.replace(/\//, "").replace(/\//g, ":");
                   var myAppleScript = 'tell application "Finder"\r';
                   myAppleScript += 'set myFolder to folder "' + myMacFolder + '"\r';
                   myAppleScript += 'set myFile to document file "' + myMacFile + '"\r';
                   myAppleScript += 'tell myFile\r';
                   myAppleScript += 'move to myFolder\r';
                   myAppleScript += 'end tell\r';
                   myAppleScript += 'end tell\r';
              }
              app.doScript(myAppleScript, ScriptLanguage.applescriptLanguage);
         }
         if (myMovedFile.exists) {
              return true;
         }
         else {
              return false;
         }
    }
    
  • doScript in other programs

    I do very little working Photosop and Illustrator.

    Is there an equivalent to doScript in these programs? A quick scan of the DOM doesn't reveal anything useful...

    Substances

    Substances wrote

    > So JS JS of launch is a no-go (use BrindgeTalk or what-have-you). Right?

    Substances, are you trying to achieve? ExtendScript has $. evalFile(), which should be available cross application...

    With InDesign you'll only use doScript to cross linguistic borders or to have these side effects on the undo history.

    Dirk

  • [CS4/JS/AS] doScript pass variable from JS to as.

    I have this doScript I want to pass a variable (theFold) to the AppleScript, he appealed:

    #target "inDesign - 6.0.

    var theFold = ["Spotlight"]

    var myScriptFolderPath = ("" HD:Users: user: Desktop Macintosh: unlock V3.app: "");

    app.doScript (file (myScriptFolderPath), ScriptLanguage.applescriptLanguage, theFold);

    AppleScript is:

    adding property: "Macintosh HD:Users: user: Desktop:

    on the run (fromJava)

    tell application "Finder".

    set name2 to (fromJava text)

    set theName to add & name2 as alias

    my openSez (theName)

    end tell

    end of race

    on openSez (theName)

    tell application "Finder".

    updated folderContents (items in folder theName)

    if (folderContents count) > 0 then

    -scroll through each item in the folder

    repeat with i from 1 to count the folderContents

    put carryThrough (section i of folderContents)

    -if this is another folder, then recurse

    if carryThrough is 'file' then

    set theName to (carryThrough as string)

    my openSez (theName)

    else

    is locked to carryThrough is true then

    locked carryThrough false game

    end if

    end if

    end repeat

    end if

    end tell

    end openSez

    Is it possible to pass a variable when calling a script from a path?

    I get the error "cannot make < script > in Unicode text.

    Thanks for any help or comments.

    Peter

    The variables are passed to a variable called arguments. You don't need an execution handler or anything like that, just:

    Name2 ((point 1 deles de arguments) text value)

    end of race

  • [JS] [CS4/Mac] doScript differs from 'normally' running

    Hi guys ' don't gals.

    Quite annoying: after writing a scenario long and tired of these undo'ing a zillion times if I made a mistake, I decided to wrap the whole thing in a call doScript. Now all of a sudden the .substr function stops working!

    Error number: 24

    Error string: expr.substr is not a function

    (...)

    Source: app.doScript (doMyStuff, ScriptLanguage.JAVASCRIPT, [things], UndoModes.ENTIRE_SCRIPT, "what the..!");

    Sound familiar?

    I had a few before clashes with string functions that seemed to work very well and stopped suddenly to work (indexOf, charCodeAt), but these seemed to disappear as if by magic. Although I have been switching written this script between Mac and Win, if they may been conflicts in a dialect of Javascript?

    This, however, is stumping me.

    You pass in variables?

    Substances

  • doScript does not

    Hi all

    below the doscript code works only with the onClick event. But when I try this without onClick event his works very well. What is wrong with him?

    dialog box. IconButton.onClick = function()

    {

    " openurl var = ' tell application \"Safari\"\ractivate\rdo JavaScript \"window.open('http://www.yahoo.com')-"in the document 1\rend say"

    app.doScript (openurl, ScriptLanguage.applescriptLanguage)

    }

    Any other suggestions for goto URL on click the button image with Javascript or Applescript.

    Thank you

    Shonky

    var linkJumper = File(Folder.temp.fullName+"/In-Tools.html");
    linkJumper.open("w");
    var linkBody = ' 

    ' linkJumper.write(linkBody); linkJumper.close(); linkJumper.execute();

    Substances

  • doScript (UndoModes) breaks InDesign Undo (CS4)

    I wrote a small script. To make sure that I can cancel it all of a sudden, I used:

    app.doScript (principal, defined, undefined, UndoModes.fastEntireScript, "My script");

    Once the script has completed, regular cancellation of InDesign is broken. It is no longer cancels distinct but only revert to the point steps until the script was run.

    What can I add at the end of the script to return things to normal?

    Thank you

    Ariel

    If you use try/catch in your script, you should probably use

    UndoModes.entireScript instead.

    The reason is little complicated...

    HTH,

    Substances

Maybe you are looking for

  • Warranty and memory expansion

    Hello I have a Satellite C650 194, which is about 6 weeks old. It has 1 GB of RAM. I was going to add more, however the plastic cover will not come off. I leave the screw and in the middle of the lid is loose, but it seems that the corners are stuck.

  • Satellite X 200-213 doesn't ' t start

    Hello, since this morning my Satellite X 200-213 not dΘmarre: stay in black screen, the hard drive seems to work (HDD led blinks and I can hear it).Anyone has an idea on the problem?

  • I can't watch DVD: error message - create failed overlay

    When I put a dvd in I click here to read on DVD Win. A message just create up to failed overlay. Low resolution of the screen or color depth. I tried both of them, but it makes no difference. Any ideas?

  • Cannot move photos - 0x80071AC3 error message

    I can't move my photos on my USB - error message is coming 0x80071AC3 - I ran the Chk dsk & he always does! Can someone help me please? I just want to remove my photos so I can give my computer to my mam, thanks in anticipation!

  • Copy JavaScript files in directory Playbook

    I'm trying to copy pictures from my application directory in the playbook photo folder. I did not javascript in a long time and not sure what I am doing wrong. Can someone tell me please the right direction? Thank you