• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

Run script when opening an AE project

Community Beginner ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

Can I run a script when I open a AE project?

I created some scripts to automate diferent projects, and was wondering if I can run specific script for each project. Maybe some call with extended script/expression?

I can't use the "startup script" because needs administrator's autorization.

Thank you!

TOPICS
Scripting

Views

287

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

There is no hook/method available so the best you can do is monitor the project name via a timer and apply certain functions depending on the name. Here is a rought example:

 

 

// Global variables
var previousProjectPath = "";

// Function to check project path and execute functions
function checkProjectPath() {
  var currentProjectPath = app.project.file ? app.project.file.fsName : "";
  
  if (currentProjectPath !== previousProjectPath) {
    previousProjectPath = currentProjectPath;
    
    if (currentProjectPath !== "") {
      var projectName = app.project.file.name.replace(/\.aep$/, "");
      
      switch (projectName) {
        case "Project1":
          executeProject1Functions();
          break;
        case "Project2":
          executeProject2Functions();
          break;
        // Add more cases for different project names
        default:
          alert("Unknown project: " + projectName);
      }
    }
  }
}

// Function to execute specific functions for Project1
function executeProject1Functions() {
  // Add your custom functions for Project1 here
  alert("Project1 functions executed");
}

// Function to execute specific functions for Project2
function executeProject2Functions() {
  // Add your custom functions for Project2 here
  alert("Project2 functions executed");
}

// Start the scheduled task
app.scheduleTask("checkProjectPath()", 3000, true);

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

Thanks! But can I use this code in expression?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

Nope, unfortunately

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

LATEST

I just found a workaround by putting the script in the local user startup folder:

C:\Users\xxx\AppData\Roaming\Adobe\After Effects\22.6\Scripts\Startup

 

I thought that only the main directory of After had the Startup Scripts folder.

Thanks for the advice!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines