Skip to main content
joshuag49458271
Participant
December 7, 2022
Question

Close Document event not firing when executed from an action

  • December 7, 2022
  • 2 replies
  • 2609 views

I have a script that creates a listener via the following code:

 

app.notifiers.add('Cls ', onClose);
app.notifiersEnabled = true;

 

It works fine when I use Ctrl W to close the document. 

 

However when I trigger an Action  that does:
Save + Close

 

It doesn't seem like that Close Document event is fired even though the document does close. 

 

Any insight into this would be amazing!

This topic has been closed for replies.

2 replies

Legend
December 8, 2022

You don't need that. You have code that closes the document, so you already know you are doing so. Just add in whatever routine you want run when the document is closed.

Legend
December 8, 2022

By the way, an alternative option - if we received a notification about the execution of an action, then we can simply read the list of commands in the active action and find out whether the close command was in it or not.

joshuag49458271
Participant
December 8, 2022

Is this possible? My understanding is that it only shoots off upon completion. 

Legend
December 8, 2022

Yes that's right. The launch of a script, action, plug-in is perceived by Photoshop as an independent event. Notifications about actions that occur within this event are not received.

 

There is no easy solution - it all depends on your script. The easiest way is to keep track of the IDs (or number) of open documents BEFORE the action is run, and compare them to what's left AFTER the action runs.

 

Action completion notification can be obtained with:

app.notifiers.add('Ply ', handler)
joshuag49458271
Participant
December 8, 2022

I've been finding that this notification event is not shooting off consistently - is that possible?