7 Replies Latest reply on Jun 4, 2015 8:28 AM by williamadowling

    Running script from actions

    subieguy2 Level 3

      I am using Illustrator CS4 on a Windows PC writing in JavaScript. I know I can't call an action via JavaScript in my version/language but I can load the script from an action. I call some scripts from my action set using the insert menu item in the action menu. However even if I save the actions with the scripts in the playlist Illustrator doesn't retain the scripts in the action set. Am I doing something wrong? Is there a work around?

        • 1. Re: Running script from actions
          williamadowling Level 4

          Unfortunately, this has been a problem for years and there's no sign that adobe has any intention to fix it. The only current workaround i'm familiar with is to simply re-add the script to the action each time you open illustrator.. It's a pain, i know, but still better than doing part of the action and then calling the script manually.


          Another option is to create a shell script that will run your action, then when the action is finished, you can run the script within your shell script.

          • 2. Re: Running script from actions
            subieguy2 Level 3

            BOOOOO  lol. Thank you for the response. I thought maybe I was doing something wrong or a preference check box I was missing. I guess I will just run the action then the script. It's not that big of a deal but every click for efficiency is important.


            Thanks again!

            • 3. Re: Running script from actions
              williamadowling Level 4

              I'm with you on that. I'm constantly fighting with my boss about things he thinks are stupid and i shouldn't spend any time on. And i always bring that up.. 5 seconds saved on one order adds up to a crap ton of saved time over the course of a year and 50,000-100,000 orders. Every click matters.


              So to that end, I'd consider trying out my second suggestion. just something like this:


              //begin shell script

              function doActionAndScript(){

                   var doc = app.activeDocument;

                   app.doScript(action, set);

                   //begin script you wanted to call from your action



              • 4. Re: Running script from actions
                subieguy2 Level 3

                By shell script do you mean something other than via ExtendScript? Because my version of AI doesn't support...

                app.doScript(action, set);
                • 5. Re: Running script from actions
                  Silly-V Adobe Community Professional

                  Did you guys see this thread : Is there a way to clear or delete actions through scripting?
                  To have scripts be accessible by an action after restart, make sure to hover over the File menu and then reload the actions by loading an action set in the actions panel. The script should then be accessible. You just have to do this every time you restart Illustrator.

                  • 6. Re: Running script from actions
                    williamadowling Level 4

                    My bad, Subie.


                    I forgot to mention that was CS6+. CS5 and prior doesn't support actions via javascript.


                    By shell script i just meant a script that holds the command for the action and then the code block for the script you wanted to call. it's just a container to do the two tasks you want to perform.


                    could you share what you're trying to do with the action? Perhaps we can script whatever was being done with the action and avoid the action step all together and just run the entire workflow as one script.

                    • 7. Re: Running script from actions
                      williamadowling Level 4

                      What's the difference between doing this and just re-adding the script/menu item? To me being required to remove and re-load the set every day is 2 steps too many.