Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Script help to determine if AE was launched from the program icon vs. a project icon

  • Script help to determine if AE was launched from the program icon vs. a project icon

    Posted by Rob Stemm on November 18, 2008 at 6:21 pm

    Is there a way to determine whether the After Effects application was started by clicking on the Program icon vs. by double clicking an .aep file? Basically I’d like a script in my scripts 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. Well the script can run in both cases, but I need a way in my script to catch which way the application was launched. Currently the script runs no matter which way I open After Effects.

    Thanks for your help,
    Rob

    Rob Stemm

    Rob Stemm replied 17 years, 6 months ago 25,332 Members · 5 Replies
  • 5 Replies
  • Rob Stemm

    November 18, 2008 at 8:59 pm

    In case any of you were wondering I had some help from the Adobe Forums.

    Paul Tuersley wrote the following
    “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 “

  • Rob Stemm

    November 18, 2008 at 9:31 pm

    I have a default folder structure which should be built into every new after effects project. If the project is not a new one, the folder structure would already exist. The problem I was running into was that a new project is created even when you open an existing project, so this is what I was seeing when I opened an existing AEP file.

    Application launches
    New Project created
    Folder structure added via startup script
    New Project attemps to close
    “Do you want to save” dialog appears because folders were added
    Action: user clicks “no”
    New Project closes
    The AEP project that was originally selected from the desktop opens

    The above is not ideal, so by delaying the script from adding the folder structure for 2 seconds we see the following behavior.

    Application launches
    New Project created
    New Project closes
    The AEP project that was originally selected from the desktop opens
    Folder structure script runs and does not add folders

    Does this make sense?

    Rob

    Rob Stemm

  • Rob Stemm

    November 18, 2008 at 9:52 pm

    I agree, but when you have 30 different artists wanting to do their own thing and you are trying to create a standard, forcing it on them with a script is easier than relying on them to duplicate a template every time. 🙂

    Rob

    Rob Stemm

  • Rob Stemm

    November 18, 2008 at 10:03 pm

    I’ve tried that and they don’t seem to understand the need. The other thing I run into with that is they create their own copy of the template on their local system. When updates are made to the template on the server they continue to use their old copy rather than the new AEP I’ve created. At least with Scripts they cannot access them and I can update them on each box remotely knowing there is only one copy of the script to keep track of.

    Rob

  • Rob Stemm

    November 18, 2008 at 10:39 pm

    Thanks for your help.

    Rob

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy