Restart/reload extension when new document is created or opened

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

ApWizard
Posts: 9
Joined: Fri Dec 16, 2016 7:39 am

Restart/reload extension when new document is created or opened

Post by ApWizard »

Hi!
I was thinking: "how to reload/restart a persistent extension when a new document is created or one is opened?"

I think I've to use

Code: Select all


app.notifier.add("Opn ", <something here>)
inside the JSX file but I'm not able to come up with something useful.

Some doubts:
  • • the example above takles the opening of a document but not the creation of a new one;
    • how do I effectively reload/restart the extension?
Thank you in advance :)
JavierAroche
Posts: 29
Joined: Sat Jul 30, 2016 3:52 am
Location: San Francisco

Re: Restart/reload extension when new document is created or opened

Post by JavierAroche »

You should take a look at this photoshop-dom-event npm module by Antonio. It lets you listen to an event and run a callback function when that event is triggered. He even has a CEP panel example.
https://github.com/antonio-gomez/photoshop-dom-event
• the example above takles the opening of a document but not the creation of a new one;
The event triggered when making a new document is "Mk ". But it is also the same for making new layers. So you'll have to read the contents of the received data to determine if the user made a new document.
• how do I effectively reload/restart the extension?
You can refresh the panel like you would refresh a browser. It's not ideal, since you'll see a flash when reloading, but it's a decent solution.

Code: Select all

window.location.reload();