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

How to detect when a project file is closes, or opens?

Enthusiast ,
Oct 22, 2013 Oct 22, 2013

Hi There,

Is there an event that AE broadcasts that allows a callback to be executed when a user closes or opens a project file from the main File menu. There are some variables in my script that I need to re-initialize when this occurs, but am unsure how can do this.  I've taken a look at the app and project objects in the documentation, but did not find anything that pertains to this.  Are there any techniques out there for initializing variables when a project file closes or opens?

Thanks,

Arie

TOPICS
Scripting
1.3K
Translate
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

correct answers 1 Correct answer

Contributor , Mar 23, 2016 Mar 23, 2016

for what it's worth, I ended up using a separate angular $interval function that invokes extendscript to check whether a file name exists every second, and triggers an event if no file name is detected. So far have had no issues with modal collision or anything else

Translate
Contributor ,
Mar 23, 2016 Mar 23, 2016

Hi Arie,

Did you ever find a way to listen for the open/close event? I have a setTimeout function that checks if a file is open every second, and then stops once it is, but am still trying to find a way to detect when a file is closed.

Translate
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 23, 2016 Mar 23, 2016

No, there are no events that get broadcast in these cases.  But, if you're using a setTimeout function, why not just keep it running indefinitely instead of turning it off once it cannot find app.project any longer?  I guess you can think of it like a beacon that is always on and when it returns something different whether or not it finds app.project.

—Arie

Translate
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
Contributor ,
Mar 23, 2016 Mar 23, 2016

Ah, I see; thanks. As for keeping the setTimeout running, I ran into performance issues by having a script running continuously like that, and it would also throw an error whenever an AE modal window opened.

Translate
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 23, 2016 Mar 23, 2016

Yes, the modals will kill it.  Before your code runs you could add app.beginSupressDialogs() that effectively shuts down that behavior.  Then when the time is shut off you can do app.endSupressDialogs(). 

— Arie

Translate
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
Contributor ,
Mar 23, 2016 Mar 23, 2016

Right-- that's the rub. If I were to run it continuously, I'd have to suppress dialogs continuously.

Translate
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
Contributor ,
Mar 23, 2016 Mar 23, 2016
LATEST

for what it's worth, I ended up using a separate angular $interval function that invokes extendscript to check whether a file name exists every second, and triggers an event if no file name is detected. So far have had no issues with modal collision or anything else

Translate
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