Copy link to clipboard
Copied
Hello, here is my issue:
I run an after effect script with the command line (the script goes through all the elements of the project). It works well when an after effect window is already launched. However if no after effect window is opened a bug appears explaining that it does not find some elements. I think that my script is executed before the complete launch of after effect and it does not find all the elements of the project. If I close the window that displays the error and I restart the same script without changing anything it works the second time because the after effect window is open.
How can I wait until after effect is fully loaded?
I tried .sleep() but it's blocking, it doesn't load the window it waits for the end of the sleep.
Thanks in advance
Copy link to clipboard
Copied
One hack that might work, depending on your situation, would be to enclose your script in a function wrapper, add it to the app object, and schedule it to run in say, 5 seconds (5000 milliseconds). Not particularly good form, but it might work for your purposes. It would look something like this:
function YourScript(){
//
// your script goes here
//
}
app.yourScript = YourScript;
app.scheduleTask("app.yourScript();",5000,false);