8 Replies Latest reply on Sep 15, 2016 7:10 AM by thunk labs

    Illustrator Applescript open command is broken

    Hanaan Rosenthal

      Hi, Scripters have been doing many different things with Illustrator over the years. One of the things that allows that is the ability to open the files we need to process. Many things could prevent a file from opening, so the open command has a nifty dialogs parameter, that allows a scripture to ask Illustrator to open a file but regardless of any issues, prevent a dialog from opening. On top of that, Illustrator can be asked to not display any dialogs at all with the user interaction property.
      Alas, the new Illustrator has a missing fonts dialog box that will not go away. It has the TypeKit logo at the top, so many folks, me included, got annoyed with TypeKit, but that was misplaced.
      Adobe: If we can't confidently ask AppleScript to open a file without it, well, not opening, we are kind of screwed.

      Please put someone on this task: When the open command is invoked with the dialogs parameter set to false, do not show the Missing Fonts dialog.
      It has to happen and it has to happen quickly.

      Thanks! Happy-scripters everywhere.

      opn.png

        • 1. Re: Illustrator Applescript open command is broken
          Hanaan Rosenthal Level 1

          More details: Adobe Illustrator CC version 18.1.1

          • 2. Re: Illustrator Applescript open command is broken
            W_J_T Level 4

            Hanaan Rosenthal wrote:

             

            Adobe:

            - Please put someone on this task:

            - It has to happen and it has to happen quickly.

             

            Sadly Illustrator lags way behind most other programs (ie: InDesign/Photoshop/etc.) in its scripting capabilities, across all provided languages. It has gotten very little added to it over the years. Also people are having issues with various things across many Adobe programs concerning scripting, as some things have become broken, etc, with Creative Cloud releases. Also please note, that we are just fellow users here, staff rarely shows up in this forum, so you may wish to file a direct complaint/bug report with Adobe on the issue if you feel it truly is broken.

            • 3. Re: Illustrator Applescript open command is broken
              Qwertyfly... Level 4

              Typekit uses of:

               

              son of a Typekit.

              go Typekit yourself.

              stop Typekitting around.

              I don't give a Typekit.

              What the Typekit.

              Holy Typekit.

              where the Typekit are my Keys...

               

              The list goes on...

              • 5. Re: Illustrator Applescript open command is broken
                hhas01 Level 1

                Aloha Hanaan, me old partner in crime...

                 

                Alas, ill-mannered dialogs have always been a problem with AI. Super annoying, but then I read about all the other horrors Adobe perpetrate on their scripting users and am personally quite glad they leave AI's Apple event support largely alone.

                 

                I'm not familiar with this particular dialog (I'm currently still slumming it on CS6 for development purposes), but I have had the exact same problem in the past with Universal Type Server's "missing font" dialogs, which don't respect any of AI's user interaction settings either. I've even had problems with AI itself throwing up "swatch conflict" dialogs when duplicating content between documents.

                 

                To what extent these missing font dialogs are AI's fault versus the font manager's fault I couldn't say offhand. I'd have to spelunk the AI SDK to see if it provides any hooks for plugins to determine AI's current user interaction settings prior to throwing up dialogs and/or instructs plugin developers to respect those settings, and frankly if I wanted to deal with AI's C* APIs I wouldn't be using its scripting interface in the first place.

                 

                Either way, as W_J_T says, you need to submit a bug report directly to Adobe if you even want them to be aware of the issue. Whether they'll bother to fix it, who can say... the entire AppleScript world ain't exactly blooming with health these days, so I doubt a fix will be high priority assuming it's even practical.

                 

                In the meantime...

                 

                The workaround I used was to create a separate 'dialog monitor' service that my AI scripting code would activate before performing a command known to trigger badly-behaved dialogs, then deactivate again once the troublesome operation was done. While running, the service would use GUI Scripting to poll the state of AI's GUI every second or so, and if it detected the appearance of a dialog would figure out what type of dialog it was and click the appropriate button to dismiss it.

                 

                Obviously, this logic had to be individually coded for each type of dialog encountered, could be a tad fragile (though I did my best to make it cope with stuff like window order changing), and tended to require updating when new versions of software were installed. But it worked well enough

                 

                As this was all running on a headless Mac, I also wrapped the problem command in a try statement that'd catch any "timeout" errors, take a screenshot of AI's UI so I could see what (if any) dialogs were displayed at the time, then kill -9 the AI process and email me a full error report before restarting AI and proceeding onto the next job as normal. That way, any time the system got stuck on a dialog I'd not seen before, I had lots of troubleshooting info available to diagnose the problem and start working on the solution for that.

                 

                Being a Python weenie I just used a background thread to run all this stuff, but as an AppleScripter it shouldn't be any harder for you to write a stay-open 'dialog monitor' applet that does the UI polling from its `idle` handler. Just have your main script run and quit the monitor applet when needed, and mind and have it deal with any timeout errors as appropriate should your dialog monitor be unsuccessful in dismissing a dialog before the command gives up.

                 

                HTH

                 

                has

                • 6. Re: Illustrator Applescript open command is broken
                  OzSanta2

                  A work around solution found, after I got frustrated by this rotten 'feature'

                   

                  Regards

                   

                  Santa

                   

                  tell application id "com.adobe.illustrator" -- Adobe Illustrator

                    try

                    activate

                    # set user interaction level to never interact

                    set user interaction level to interact with all

                    repeat until the (count of documents) is 0

                    close every document saving no

                    end repeat

                    set addBarCode to false

                    set my theItem to my theItem as alias

                    try

                    tell application "System Events" to tell process "Adobe Illustrator"

                    try

                    keystroke return

                    end try

                    end tell

                    activate

                    set theDwell to 16

                    set theStartTime to current date

                    with timeout of theDwell seconds

                    try

                    open my theItem dialogs no

                    end try

                    end timeout

                    if (current date) - theStartTime > theDwell - 1 then

                    set The_app to "Adobe Illustrator" as text

                    try

                    tell application "Finder"

                    tell application "System Events" to set pid to the unix id of process The_app as Unicode text

                    do shell script "kill " & pid

                    end tell

                    end try

                    my transferMessage(currentMailItem, "* items to manually process")

                    my sayTheText:("We may have struck an Illustrator file with miss matched fonts. It has been moved to the mail box items to manually process")

                    end if

                    -- as alias (don't use 'as alias' or routine won't work)

                    on error errmsg number errnum

                    tell application "System Events" to display dialog "setup 1 " & errmsg

                    end try

                    repeat 2 times

                    tell application "System Events" to tell process "Adobe Illustrator"

                    try

                    click button "Continue" of window 1

                    end try

                    try

                    keystroke return

                    end try

                    end tell

                    end repeat

                  • 7. Re: Illustrator Applescript open command is broken
                    OzSanta2 Level 1

                    It struck me that my above script just Quit Illustrator, and called my routine to move the Illustrator-file-containing-email to a particular Mailbox. It did NOT allow the bypassing or re-setting of the problematic dialog box.

                     

                    This script DOES allow the bypassing of the dialogs, and if you amend it, it could call up any other handlers for getting the user to acknowledge any missing fonts.

                     

                    Regards

                     

                    Brian Christmas (aka Santa)

                     

                    property TheItem : ""

                    set my TheItem to ((path to desktop) & "KPR_13939_SaveTheDate_FOIL 9.48.02 AM.ai" as text) as alias

                     

                    tell application id "com.adobe.illustrator" -- Adobe Illustrator

                      activate

                      # set user interaction level to never interact

                      set user interaction level to interact with all

                      repeat until the (count of documents) is 0

                      close every document saving no

                      end repeat

                      set addBarCode to false

                      set my TheItem to my TheItem as alias

                      try

                      tell application "System Events" to tell process "Adobe Illustrator"

                      try

                      keystroke return

                      end try

                      end tell

                      activate

                      set theDwell to 16

                      set theStartTime to current date

                      with timeout of theDwell seconds

                      try

                      open my TheItem dialogs no   -- as alias (don't use 'as alias' here or routine won't work)

                      end try

                      end timeout

                      if (current date) - theStartTime > theDwell - 1 then

                      activate

                      tell application "System Events" to tell process "Adobe Illustrator"

                      try

                      keystroke return

                      end try

                      do shell script ("sleep 0.4")

                      try

                      keystroke return

                      end try

                      end tell

                      tell current application to say ("We may have struck an Illustrator file with miss matched fonts. Fonts have been replaced by default fonts")

                      end if

                      on error errmsg number errnum

                      tell application "System Events" to display dialog "setup 1 " & errmsg

                      end try

                      repeat 2 times

                      tell application "System Events" to tell process "Adobe Illustrator"

                      try

                      click button "Continue" of window 1

                      end try

                      try

                      keystroke return

                      end try

                      end tell

                      end repeat

                    end tell

                    • 8. Re: Illustrator Applescript open command is broken
                      thunk labs

                      For those interested here's how I finally got my script to work around the TrueType dialog by simply closing it instead of replacing fonts (albeit with a 20 second timeout per file). Most of this is taken from OzSanta2, but hitting esc will dismiss the dialog as though you clicked the Close button. Here's the meat of it:

                       

                      set theDwell to 20

                      set theStartTime to current date

                      with timeout of theDwell seconds

                        try

                        open POSIX file sourcePath as alias without dialogs

                        end try

                      end timeout

                      if (current date) - theStartTime > theDwell - 1 then

                        display notification "Open .ai file timed out. Hitting esc."

                        tell application "System Events"

                        key code 53 -- hit esc

                        end tell

                      end if