4 Replies Latest reply on Nov 7, 2009 7:44 AM by Paul_E36

    Startup Script to run if application is launched vs project launched

      Is there a way to determine whether the After Effects application was started by clicking on the Program icon or by double clicking an .aep file. Basically I'd like a script in my startup folder to run if the application was started by clicking on the application icon and to not run if an already existing project was double clicked to open After Effects.

      Thanks for any advice.

      Rob
        • 1. Re: Startup Script to run if application is launched vs project launched
          Hi Rob,

          Assuming your existing project actually has items in it, you might be able to check if app.project.numItems > 0 to proceed with the script or not.

          Note that you can't just check if the app.project.file == null because a project saved in an earlier version of After Effects will come in as untitled.

          Hope this helps.

          Jeff
          • 2. Re: Startup Script to run if application is launched vs project launched
            Paul Tuersley Level 4
            At first I didn't think so. After Effects runs the startup script before opening the project, and the script doesn't have access to that information.

            But I have managed to come up with this:

            {
            function check() {
            //if (app.project.file == null) {
            if (app.project.numItems == 0) {
            writeLn("AE was opened with no project");
            } else {
            writeLn("AE was opened with a project");
            }
            }

            app.scheduleTask("check()",1000,repeat=false)
            }

            I'm using app.scheduleTask to get the main part of the script to run one second later. This seems to be enough time for a project to start loading if there is one, and the script then runs after the project has loaded.

            At first I was checking if the project had a file path (app.project.file == null) but this wasn't catching projects that opened as untitled.aep due to importing an older project version, so I changed it to check if the project was empty (app.project.numItems == 0).

            Paul
            • 3. Re: Startup Script to run if application is launched vs project launched
              Level 1
              Thanks for your help Paul. This worked well for my particular application.

              Rob
              • 4. This does not work stably
                Paul_E36

                I have script in "C:\Program Files\Adobe\Adobe After Effects CS4\Support Files\Scripts\Startup"

                 

                function check()
                  {
                if (app.project.numItems != 0)
                  {   writeLn("AE was opened with a project");   } 
                else  {  writeLn("AE was opened with no project");  }
                }

                app.scheduleTask("check()",5000,repeat=false)

                 

                Then i double clik to empty project script write me in info window correctly.

                Then i double clik to big project (about 45Mb and time of load about 30 sec) script not load and write.

                I tried to change the setting repeat=true  because when loading the project do not see the inscription. no effect

                I tried to change timeoute to 50 sec (50000) script run correctly.

                 

                I need to load the program with project without interface and then run the script. how can I do this in automatic mode?

                 

                operation system - WinXP SP3

                 

                Thanks for your help