[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.

Tags: InDesign

Similar Questions

  • 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"));
    
  • 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

  • Photos app contains iPhoto events, do not understand.

    Since the upgrade of the Mavericks to Yosemite (and now ElCapitan) my photo library contains my old iPhoto events. Here are my questions:

    (1) my iMac shows that I have 27 000 photos, but all my other devices I have 11 000 pictures.

    (2) ' iPhoto events' contains 393 events, but many of them are grayed out? These photos to go and how can - I recover?

    (3) I still have the iPhoto application. Can I trash the app or will remove that somehow all my iPhotos currently on the Photos app? Is it possible to merge the iPhoto events in the rest of the Photos app so that I don't have to deal with the old iPhoto?

    1 & 2.  A great basic list may take several days, or even weeks, to migrate and syncs to iCloud, then to your devices. The 'missing' and grated the elements, might simply need more time.

    3. Yes, finally you can remove the iPhoto app and the iPhoto library, but leave the long until you're absolutely, positively sure that the migration to the Photos is successful. There are no big rush, that you won't get a lot of accumulation by removing.

  • 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";

  • How to use jsxbin and #targetengine within a jsx file in ILLUSTRATOR?

    I found many solutions for InDesign, but not for Illustrator. They use app.doScript () after you set the #targetengine, BUT this does not work in Illustrator!

    What I want: convert my code finished JSXBIN, so that nobody can read/rewrite of the code. So I want to insert the JSXBIN does in a jsx file where I call the #targetengine, so that the code remains active. (bridgetalk, palette window, etc.).

    I lost a lot of time now

    You have any ideas? Tips? workaround solutions? dirty stuff? No matter what?

    THX!

    Ok. I have it.

    The problem is that I had a function that I sent to bridgetalk as func_name.toString (), after conversion to binary jsxbin, the code of this function could not be executed. I removed these func_name.toString () command and replaced by the entire function as string!

    thx a lot!

  • Run the Script on the Open Document event

    OK so I know about the spectacle of afterOpen and I think I understand how to use it, however, I do not understand how to open to a specific document.

    I don't want this script runs on all the documents that I opened, I would like to incorporate into a document and then run it whenever I open this document. Is this possible?

    Maybe run the script in the script label?

    Or I just put a script in the start Panel, and then create a session script that checks the name of each document open and then runs the script, if I have a match?

    Thank you

    As you chart put it in the startup scripts folder

    //startup script
    #targetengine "session"
    main();
    function main(){
        var myEventListener = app.eventListeners.add("afterOpen", excuteScriptLabel);
    }
    
    function excuteScriptLabel(myEvent){
              //The parent of the event is the document.
              var myDocument = myEvent.parent;
        if (myDocument.constructor.name == "Document") {
            if (myDocument.label != "")
                app.doScript(myDocument.label, ScriptLanguage.javascript);
        }
    }
    

    Then try this line on a document and save it, and then open the same file and a few others, you will notice that this code only run on this document:

    app.activeDocument.label = "alert (\"Yes\");";
    
  • Compiling jsx to jsxbin, Palette disappears during the race

    Hello world

    My ID version is CS5, I added # targetengine "session."

    I compile jsx to jsxbin, but the palette disappears during the race.

    Anyone can tell me the reason?

    Thank you.

    Best regards

    Goldbridge

    You can wrap the content of jsxbin inside app.doScript () routine and add engine target in front of her.

    Hope that helps.

    --

    Marijan (tomaxxi)

    http://tomaxxi.com

  • 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 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

  • problem with update of apps - ann unknown error occurred 11503

    Almost daily when I try to update my IOS apps in iTunes I get error - ' could purchase < app > an unknown error has occurred. There was an error in the iTunes store' with error 11503. This is the case most of the time but not all the time. If I try again later, I am sometimes able to update applications. I check the status of the iTunes store and it shows no problem. I log out and back in iTunes (last verse.) and it does not help. The solution is to make the app on the device (iPhone, with the latest IOS) updates. There's other light this or you will suggest fix?

    I know with iOS9 that apple went to a more direct service provider device app store. The main difference was you could are no longer synchronized apps from a device to iTunes, but you could still make it on the other hand, as well as download on iTunes. With "thinning" each device has received a version customized for a specific application for the model of the device but if you downloaded iTunes no thinning version was as long as it works on any iOS hardware. It is in itself would not explain your experience, but I wonder if it is somehow connected and perhaps it is not a version not cleared up (wild guess)?

  • Events in the application calendar keep disappearing.

    Calendar App keeps losing events. At first I just assumed I had deleted by mistake. So I made a mental note of what I had entered. Now, today they are still missing. I don't use icloud, and I didn't do it the calendar sinked with any other device. I'll do a 'PR' reset and backup sweater, just want to know whether it is a known issue or if there may be something I am doing wrong. Use app calendar for years without any problem. Sorry for posting in iCloud, but it won't let me post anywhere else.

    Is this a new problem with El Cap. With no synchronization to iCloud, it is a bit of an oddity.

    Re-installing the Combo update on top of your existing for OSX Download OS X El Capitan 10.11.5 Combo Update

    Try to iCloud and synchronize the calendar with the cloud even with any other device.

    With your same Apple ID, you can register for a free developer account and start a conversation with Apple engineers

    Bug Reporter https://bugreport.apple.com/

  • Event of LabVIEW transformation in an external library (DLL) :-(locks


    Yes, I tested this solution and got to work.

    I see why Labview creates its own queue for events in such a way that callback events are not processed within the DLL code is and are waiting to return in Labview.

    And when I call the DLL inside another function that executes another asynchronous process (enumeration) this way active queue processing in the application.

    It's a strange and not obvious situation.

    I only discovered that all of a sudden this possibility during debugging.

    I don't see other solutions and cancel this topic.

    Best regards

    Anatoly

  • activeX event

    Hello
    I am using a calendar ActiveX http://shareme.com/details/calendar-activex-control-sdk.html

    In Help:

    "

    OnDayClick
      Occurs when you click in the living area.

    Sub Calendar1_OnDayClick (ByVal iYear As Integer, ByVal iMonth As Integer, ByVal iDay As Integer, ByVal strText As String)
    Parameter
    iYear - the year you selected.
    iMonth - the selected month.
    iDay - the selected day.
    strText - the text of the day if they are available.

    Return value

    No return value.  

    Example of

       

    Visual Basic syntax
    Private Sub Calendar1_OnDayClick (ByVal iYear As Integer, ByVal iMonth As Integer, ByVal iDay As Integer, ByVal strText As String)
    txtCurDay = iDay
    txtDayText = strText
    End Sub

    "

    But I have really no idea to implement this!
    I just want to have the date when I click on the calendar!

    Any idea?

    Best regards

    I found the solution with the callback event.
    LabVIEW is fantastic... :-)

    Thank you all.

  • Long-term headless app work: QTcpSocket receive do not

    We have an app without long-term head that uses sockets for IPC.

    Headless part contains a QTcpServer, the user interface of the QTcpSocket.

    the code without a head:

    server = new QTcpServer(this);
    bool ok = connect(server, SIGNAL(newConnection()), this, SLOT(onNewConnection()));server->listen(QHostAddress::LocalHost, m_port);
    

    user interface code:

    bool stateOk = connect(clientSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(onStateChanged(QAbstractSocket::SocketState)));
    if (!clientSocket->isOpen()) {
        clientSocket->connectToHost(QHostAddress::LocalHost, m_port);
        bool conOk = connect(clientSocket, SIGNAL(connected()), this, SLOT(connected()));
        bool disconOk = connect(clientSocket, SIGNAL(disconnected()), this, SLOT(disconnected()));
        bool readReadOk = connect(clientSocket, SIGNAL(readyRead()), this, SLOT(commandReceived()));
        bool errorOk = connect(clientSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error(QAbstractSocket::SocketError)));
        Q_ASSERT(errorOk);
        qDebug() << "connected to server socket";
    }
    

    output debug shows headless headless app is running constantly, the signal is properly connected, the socket for the server returns isListening() to true.

    debug output of the user interface shows that all signals are correctly connected, and onStateChanged goes from HostLookupState to ConnectingState and finally to ConnectedState

    At this point, I'd wait the server socket to pull the signal of newConnection, but alas, it isn't.

    I generate and run the xandos example and it works correctly, but it does not long-term use and has the server in the user interface, while the part without head connects.

    I suspect that the app without head doesn't have an event loopand QTcpServer documentation states:

    Although QTcpServer is mostly designed for use with an event loop,it's possible to use it without one.In that case, you must use waitForNewConnection(),which blocks until either a connection is available or a timeout expires.
    

    Now I wonder:

    The long March without head app has an event loop?

    If this is not the case, how best to use the blocking call without disabling the rest of its features? A thread?

    Write that post little got me on the right track already, a problem merging caused the socket to the server must be started before you call the constructor of the Application (which provides the event loop).

    Now the server is running, receive a few orders, then she stops unexpectedly, the fires of the user interface
    QAbstractSocket::RemoteHostClosedError changes the State of ClosingState and UnconnectedState

Maybe you are looking for