Calling an applescript inside a Javascript, waiting for it to complete before moving on.

I've got a handly little applescript compiled as an app that performs an Adobe Illustrator action which exports the current file's artboard #1 to a specific location at 300ppi. I can even call it from a javascript... which is great because I want a javascript that will loop x times, changing text and exporting on each each loop. But, each loop will export a file with the same name... not a problem, I'll rename the file after each loop, and javascript will wait patiently for me the export to complete before moving on to the next step, right? Wrong! Javascript just keeps moving through the script.
So, how do I get Javascript to wait until the AppleScript completes the export? I can't have it wait a specific amount of time...export might take between 2 and 180 seconds.
My ideas:
1) can the applescript fire some sort of event letting Javascript know to move on?
2) Is there a Javascript equivalent to AppleScripts "do javavscript " command, which would allow me to move the Applescript code into my core javascript?
3) I could kludge a stopwatch on the first loop, checking every 10 milliseconds to see if the exported jpg file has been written... then using that as a baseline timer to pause later loops (not great, because the file will exist while AI writes it, and JS may rename it and try to export the second loop before the first is done).
for (z =0; z<copyArray.length; z++) {
var jpgExt = "-01.jpg";
var newExt = ([z] + jpgExt);
var exportASfile = File('/Applications/Adobe Illustrator CS5.1/Presets.localized/en_US/Scripts/VCS_Specialty Scripts/StandardExport.app');
exportASfile.execute();  // export the file
renamedFile = new File(exportFile); //variable exportFile is a reference to the jpg being written by the export
renamedFile.rename (exportFile.name.replace(jpgExt, newExt)   ); // replaces part of the filename with a new

I'd love to stay in one language, but since we're stuck on CS5 here, I have to make do.
My task for the script:
1) pop up a window to collect: 1a) number of copies, 1b) custom text, 1c) choice of three radio buttons -- I can't figure out how to do this in AS besides popping up three separate dialogs, I have it working great in JS
2) loop step 1, write a named text frame with an array value containing a concatenation of 1a, 1b, 1c  -- pretty easy in either
3) loop step 2, export the file at a higher than 72ppi resolution with artboard -- currently controlled by an action, can't be done programmatically in either AS or JS using CS5
4) loop step 3, rename the file to match what was written to the text frame -- again, pretty easy in either
In CS5, neither JS or AS have the ability to control the resolution of a jpg when exporting.... just the scale. So an action is required.
My window JS has some of the basic edittext, statictext, buttons, panels elements, not too tricky:
var win = new Window ("dialog","Cover Copy Builder");
    win.orientation = "column";
    win.add ("statictext", undefined, "Copy and Format Instructions");
    var input = win.add('panel', [0,0,320,300],  undefined, {borderless:true} );
    win.add ("statictext", undefined, "Output Summary");
etc.
Is there an AS equivalent to this sort of window building construction?

Similar Messages

  • Wait for Event FIPP - Completed Logically Deleted

    Hi WF Experts,
    We have a WF for Release of payments.
    It has 1 Fork with 2 parallel branches (both necessary).
    1 Branch has the approval process for Amount release and the other branch calling the Account assignment approval Subworkflow.
    The approval process branch has the until loop with increment counter and it picks the agents within the loop until a loop condition is reached and thereby till no more approvals required.
    The other branch, before calling the subworkflow, it checks a WAIT FOR EVENT FIPP->COMPLETED with container element FIPPID.
    Both these branches needs to be completed so that the forks gets ended and the wf comes out of the fork.
    The approval process branch is working perfectly. But in the other branch the WAIT FOR EVENT FIPP->COMPLETED  gets logically deleted and thereby, this branch does not go firther to start the Account assignment approval Subworkflow. This way the Fork with the 2 necessary branches does not end, and thereby, the WF stops here and could not go further to set release indicators (Which is a backgorund task).This will confirm the end of WF process.
    When I pass the WI ID for this Wait event in the SWIA, it shows the status as CANCELLED.
    The WF User log as a whole shows the status as COMPLETED as all the approvers has approved the release.
    Why is the Wait for Event gets logically deleted ?Please advice.
    Edited by: Sameer Anwar on Jun 12, 2011 9:17 AM
    Edited by: Sameer Anwar on Jun 12, 2011 9:21 AM

    Dear Experts,
    Any update on this . I am unable to sort this out why the Workflow is getting stopped.
    -Anwar

  • Wait for execution to complete

    Hello,
    I have a simple question about the "wait for execution to complete" option by using new execution:
    does the caller wait for the end AFTER executing the Cleanup, or just after the Main sequence?
    regards
    Solved!
    Go to Solution.

    At the end of Cleanup at the <End Group> tag.
    Hope this helps,
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • Hi i was in the process of uploading photos from my phone three days ago- and have tried to re start  my computer but cannot get out   of " Photos are being import to photo library please wait for import to complete"there are 90 photos and this came

    Hi I was in the procces of uploading photos from my phone three days ago as i have an important art project to finish today. I have tried to restart my computer log off come back on but every time i put my phone to the computer and press up load photos its comes up with "Photos are baeing import to photo library- please wait for import to complete".
    There are 90 photos and this came after it uploaded a few - can you help me - i have tried to quit iphone but this keeps coming up and i need these pics imported from my phone to my computer.
    please help
    thank you

    Apple menu ==> forec quit
    LN

  • Message "waiting for job to complete..." for printing

    Hello,
    I have a printer installed on Windows Server 2008 R2, shared for a
    windows 7 computer (OK), and a Macbook Air 10.8.3. m.lyon. (KO) is installed and configured correctly. HP Deskjet 3940.
    But in the MacBook when I print any document send the form to the
    Windows tail, and appears well in line, even tells me not just printing but printing ever, life is printing but printing out the document, including the correct printer makes noise as to be printed but nothing .
    On the MacBook print queue the message remains "printing: waiting for job to complete ..." and never complete.
    I install the printer on the Windows icon in Printers & Scanners for smb
    for the default printer and the result is always the same.
    Connect the printer directly to a USB port on the MacBook to try and charge good drivers and printed the first ....
    I need help, can you help,
    thanks,
    Joan.

    I solved this as follows....
    Go to the Windows computer.
    Open printers and select the printer
    Go to Customize your printer
    Go to ports
    Disable "Enable Birectional Support" in the Ports
    Sounds crazy, but it worked.
    Good luck, YMMV.

  • What should I do if the iphoto keeps on saying that "Plz wait for import to complete" when i click the close button but it is not importing photos? How can I close the iPhoto? I try to switch my mac off but it doesn't work. Thanks.

    What should I do if the iphoto keeps on saying that "Plz wait for import to complete" when i click the close button but it is not importing photos? How can I close the iPhoto? I try to switch my mac off but it doesn't work. Thanks.

    You should be able to select Force Quit from the menu beneath the Apple icon in Finder
    and choose to Quit iPhoto from there, without messing up the Mac OS X in the process.
    OS X - Support
    Not sure if rebuilding the iPhoto library would help this issue. However if you had to
    turn off the computer without the correct method (unplug, etc; instead of menu choice)
    the system may have accrued damages and should be checked, maybe repaired by
    use of the Disk Utility in the system. Or restart the computer in Safe Boot mode, then
    run 'repair disk permissions' while it is running in that reduced mode; then restart after.
    •Understanding Safe Mode - tuts+ computer skills tutorial:
    http://computers.tutsplus.com/tutorials/understanding-safe-mode--mac-59897
    •OS X: What is Safe Boot, Safe Mode?
    Suggestions on how to use Safe Mode in article, to resolve issues, may be helpful.
    There likely are other means to rectify troublesome applications, including reinstall.
    Be sure to backup your music, image, video, and other work on an external drive
    or suitable device as a precaution against loss should there be a hard drive failure.
    iPhoto - Mac Apps - Apple Support
    There should be some tips and help information using iPhoto via this tiny Support link.
    Good luck & happy computing!

  • Wait for a few minutes before starting a backgroung step in workflow

    Dear All,
    I have a requirement where in I have to make sure the user has completed a particular workitem. The workitem is to open the transaction PP02. I cannot make it asynchronous and use a terminating event as I could not see any logical place where I could trigger the terminating event on SAVE.
    Now, I am trying to check if the database is updated on save of the transaction and before I do that I would want the workflow to wait for a few mintues.Is this approach correct?
    Is there any way I can make the workflow to wait for a few mintues before it starts the next backgound step?
    Please suggest.
    Best Regards
    Vikram

    I think it is better option to use the WAIT Step 
    as you said that until you save the data in the trabsaction you don't want to proceed further then, try like this
    Create a wait step and use the option wait for condition.
    define a element in the workflow of type char01( assume TEST) .
    Pass X to this element from the transaction when ever you save the data.
    and define the condition for the wait step in such a way that until the value of TEST = X do not proceed further.

  • I plugged my phone in and I'm trying to upload photos like I usually do but iPhoto is saying "Please wait for import to complete". It won't let me close iPhoto or anything. Help please!

    I plugged my phone in and I'm trying to upload photos like I usually do but iPhoto is saying "Please wait for import to complete". It won't let me close iPhoto or anything. Help please!

    apple menu ==> force quit
    LN

  • Every time I start my Apple TV it shuts down. I have to unplug it and wait for it to reconnect before I can use it.  Any suggestions?

    Every time I start my Apple TV it shuts down. I have to unplug it and wait for it to reboot before I can use it.  This makes turning on Apple TV a very long process.  Any suggestions?

    That would be very hard to do, as I would have to do a lot of things--including moving furniture to get at the back of a receiver--and I'm not at all sure that the receive could accommodate it.
    The process is like this:  I dial the receiver to the Apple TV input.  The light comes on, like it's connecting, but then the Apple TV goes dark before any connection happens.  Then I unplug the power cord, wait a few moments, and plug it back in.  Then the Apple TV actually connects, but only after a full reboot (setting time, etc).

  • My Mac laptop IPhoto is "stuck" on a screen that says, "Please wait for import to complete."  I can't get it to complete the task.

    My Mac laptop IPhoto is "stuck" on a screen that says, "Please wait for import to complete."  I can't get it to complete the task.  What do I do next?

    Force Quit the app. It's under the File menu.

  • I cannot close or import or any function to iphoto.  I have been getting the same message for many days "Photos are being imported to the photo library.  Please wait for import to complete."  I do not know where the photos would be importing from.

    I cannot close or import or any function to iphoto.  I have been getting the same message for many days "Photos are being imported to the photo library.  Please wait for import to complete."  I do not know where the photos would be importing from.  How do I get it to proceed?

    After Force Quitting, as LarryHN recommended,
    Select the iPhoto Library in the Finder. By default it is in your Pictures folder.
    Ctrl-click or right-click the iPhoto lIbrary. Select "Show package contents" from the panel, that will pop up.
    Look for a folder named "Importing" or "Import". Remove this folder, but don't touch anything else.
    Then launch iPhoto again.
    If iPhoto now is working again, check the folder you removed, if there are any photos that you want to keep and save them.

  • Officejet pro 8600 waiting for job to complete on Mac

    Hi
    I have the problem where after printing the I get the message "waiting for job to complete" which never goes away by itself. I can manually delete the item and then continue to print repeating the process every time I need to pringt.
    I have read the forums and found similar issues but not exactly the same and the recommendation for that was to reset the print system and resinstall. I did that but the problem persists.
    Printer: Officejet pro 8600 Plus
    OS: OSX 10.9.3
    Connection: Wireless and  USB (same issue with both)
    When I initially installed the printer it worked fine. When I upgraded to 10.9 it worked fine but the problem arose soon after.
    Thanks
    This question was solved.
    View Solution.

    Welcome to the forums MedlandLime,
    I understand you are seeing a message saying "waiting for job to complete" after you print and the message will not dissipate. I saw that you have reset the print system and reinstalled and the message continues. I have some more ideas that might help.
    First of all, test the printer hardware itself and make a couple of copies. If the copies work fine, the printer is okay!
    Next, try updating the printers Firmware through the front panel: Getting the Latest Firmware and Product Updates
    If the issue still persists, follow these steps in order:
    Mac OS X: How to reset the printing system
    Repair disk permissions
    Restart the computer
    Re-add the printer and ensure it's the HP driver and not the AirPrint driver: HP Officejet Pro 8600 series Full Feature Software and Driver- OS X 10.9 Mavericks
    Please let me know the results!
    Have a great Monday
    R a i n b o w 7000I work on behalf of HP
    Click the “Kudos Thumbs Up" at the bottom of this post to say
    “Thanks” for helping!
    Click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution!

  • Javascript: Wait for a redirect to complete - creating multiple PDF's

    Hi!
    Here is the code that I am using to try to generate multiple reports from javascript. how do I wait for the redirect to complete (ie. generate the PDF) before redirecting to generate the next PDF?
    In the code the "F106_" are application level items.
    I get have been able to get the very first or the very last PDF but none of the other PDF's.
    <script type="text/javascript">
    function f_DoReport() {
      for (i = 2; i <= 3; i++)
         for (j = 1; j <= 4; j++)
             var rgn = '0' + i;
             var dst = '0' + j;
             var vurl = 'f?p=&APP_ID.:30:&SESSION.:FLOW_XMLP_OUTPUT_R27022113101536736_en-us:&DEBUG.::';
             vurl += 'F106_RPT_REGION,F106_RPT_DISTRICT:' + rgn + ',' + dst;
             redirect(vurl);
             alert('rgn: ' + rgn + ' dst: ' + dst);
    </script>Please let me know if I am going down the wrong path here. :D
    As always thanks for your time and help!
    Dave Venus

    A few questions…
    Do you want a script that works with just the active document and you are going to run 300+ times? If so then this may do…
    #target illustrator
    function artboardsToPDFs() {
         if (app.documents.length = 0) {
              reurn;
         } else {
              var docRef = app.activeDocument;
              var docName = docRef.name;
              var baseName = docName.replace(/.ai$/,'');
              var dF = docRef.path.fsName;
              var aB = docRef.artboards;
              var pdfOpts = new PDFSaveOptions();
              pdfOpts.pDFPreset = '[Press Quality]';
              for (var i = 0; i < aB.length; i++) {
                   var numb = (i+1).toString();
                   pdfOpts.artboardRange = numb;
                   var pad = aB.length.toString().length;
                   numb = zeroPad(i+1, pad);
                   var pdfFile = File(dF + '/' + baseName + '_' + numb + '.pdf');
                   if (!pdfFile.exists) {
                        docRef.saveAs(pdfFile, pdfOpts);
                   } else {
                        var rPDF = confirm('File: "' + pdfFile.name + '" already exists…\rDo you wish to replace?',false);
                        if (rPDF) {
                             docRef.saveAs(pdfFile, pdfOpts);
                        } else {
                             continue;
    artboardsToPDFs();
    function zeroPad(n, p) {
      var t = n.toString();
         while (t.length < p) {t = '0' + t};
      return t;
    Do you want to pick a folder of all the illustrator files? If this is the case I would need more info and it would take longer…

  • Wait for Event not Complete

    I have a Wait for Event step in a simple workflow. My problem is that the step won't complete even if the event is already triggered.
    In SWEL, the event is there, and Object Key and everything else seem right to me. And the Work Item Instance is there too. Check picture 1 for screenshot of Event Trace.
    In SWI1, everthing is fine except that the Wait for Event has only one action "Wait step Created". The WorkItem ID is the same as Receive Object Key in Event Trace. The object in the Wait step has an instance and LPOR is correct.
    The configurations in Instance Linkage is also attached. I suppose it should be automatically added when Wait for Event is set up in the workflow. But there was no entry so I had to do it manually. I also tried Receive Call method CL_SWF_RUN_HANDLER_EVT_RECEIVE. The result was the same.
    A screenshot of SWU0 is also attached. To me it says "something is wrong" which I already know well.

    Hello,
    "I have a Wait for Event step in a simple workflow. My problem is that the step won't complete even if the event is already triggered."
    What should the workflow do when that event is detected?
    "In SWEL, the event is there, and Object Key and everything else seem right to me. And the Work Item Instance is there too. Check picture 1 for screenshot of Event Trace."
    I agree, it looks okay.
    "The configurations in Instance Linkage is also attached. I suppose it should be automatically added when Wait for Event is set up in the workflow. But there was no entry so I had to do it manually."
    There is no need to do that, in fact it may be causing the problem. Try removing it.
    "A screenshot of SWU0 is also attached. To me it says "something is wrong" which I already know well."
    Why do you say that? I would use SWUE to create the event.
    regards
    Rick Bakker

  • Multitasking - Have to wait for card to stop before selecting

    I have noticed that when multitasking, I have to wait for the cards to completely stop moving before I can interact and touch them. I am unable to select a card while they are animating.  Is this normal?

    The app cards. I call them cards, I could be using an incorrect term, but the currently running app windows/screenshots/previews that you interact with by swiping up to close the app or touch to select to go into the app.

Maybe you are looking for

  • Closing Stock of Plant at BPC level

    Hi Experts, I am very fresher to work on BI-BPC integration project for SAP ABAP. Requirement is like we have input of TIME, PLANT, MATERIAL for this we need to fetch closing stock of material in BPC reprot. Closing Stock will not come directly from

  • Show/Hide a column in a Table region

    I have search page which queries the data and displays the records in a table region. We need to have an option to show or hide a non-database column at the end of the each row in the table. If the checkbox is selected, the last column should appear

  • Why is the latest version of Firefox such CRAP??

    Features removed, UI setup not remembered Unable to put tabs where you want them Customisation of button bars screwed up etc etc etc etc

  • Roll Over

    I'm trying to create a simple roll over. I want the normal picture on load, and then when they touch it, it changes to the next picture. Here are the 2 files: arch1.jpg -first picture (original) archives3 copy.jpg -second picture(on rollover) If anyo

  • Submit jobs

    Hi, I'm trying to use mac desktop as a cluster to run models. My desktop has 12 processors and 48G Memeory, and I've installed all the packages I need to run models parallelly. I just have the final question that how to submit a job script on mac. I