Skip to main content
c.pfaffenbichler
Community Expert
Community Expert
June 3, 2010
Answered

what’s the notifier for starting the application

  • June 3, 2010
  • 1 reply
  • 6047 views

Recently I’ve been accidentally made aware of how to use notifiers in a thread in this Forum and a Feature Request-post seemed to provide a good example for using it.

The poster there was dissatisfied with Brushes.psp being updated on quitting, thus making users lose all newly created brush presets on crashing, unless one saved them manually in between.

Overwriting Brushes.psp seems a bit harsh, so I linked a Script that saves all brush presets as a new file »all.abr« into the Presets – Brushes-folder to »Mk  « for »Brsh«.

Another Script, which compares the change dates of »all.abr« and »Brushes.psp« and offers a confirm for loading »all.abr« in case it is the younger file, is linked to »Ntfy« but on starting Photoshop it is executed twice apparently.

(This is the code I used to set up the notifiers:

if(!app.notifiersEnabled) {app.notifiersEnabled = true};

app.notifiers.add("Mk  ", File("/Applications/Adobe%20Photoshop%20CS4/Presets/Scripts/saveBrushSetAll.jsx"), "Brsh");

app.notifiers.add("Ntfy", File("/Applications/Adobe%20Photoshop%20CS4/Presets/Scripts/loadBrushSetAll.jsx"));

)

So is »Ntfy« the wrong event or is there a likely reason within the Script itself that makes it run twice?

Any advice appreciated.

This topic has been closed for replies.
Correct answer Michael_L_Hale

Thanks.

But is it standard behaviour that the Script runs twice when linked to »Ntfy«? (Which I notice because it has got a confirm().)


The start event does fire twice. The first time the descriptor has 3 key, the next it has only one. So if you wrap your code in an if statement you can have the script only run once.

if( arguments[0].count == 1) alert( 'done');

1 reply

Inspiring
June 3, 2010

app.notifiers uses the same strings for events as the Script Event Manager. Those are listed in the guide. I don't have access to it here or I would post the one for application start.

One advantage for using app.notifiers instead of the Script Event Manager is that you can use stringID events and you can limit to a class.

c.pfaffenbichler
Community Expert
Community Expert
June 4, 2010

Thanks!

I tested »Ntfy« with a simple alert-Script and that also seems to be run twice.

In »Photoshop CS4 JavaScript Ref.pdf«’s »Appendix A: Event ID Codes« I could not identify an event for application start.

Are you referring to another guide?

Paul Riggott
Inspiring
June 4, 2010

This a standard Script Events Manager.xml file Christoph...


<ScriptEventsManager>
<events>
  <0>
   <name>Start Application</name>
   <value>Ntfy</value>
   <valueClass></valueClass>
  </0>
  <1>
   <name>New Document</name>
   <value>Mk  </value>
   <valueClass>Dcmn</valueClass>
  </1>
  <2>
   <name>Open Document</name>
   <value>Opn </value>
   <valueClass></valueClass>
  </2>
  <3>
   <name>Save Document</name>
   <value>save</value>
   <valueClass></valueClass>
  </3>
  <4>
   <name>Close Document</name>
   <value>Cls </value>
   <valueClass></valueClass>
  </4>
  <5>
   <name>Print Document</name>
   <value>Prnt</value>
   <valueClass></valueClass>
  </5>
  <6>
   <name>Export Document</name>
   <value>Expr</value>
   <valueClass></valueClass>
  </6>
  <7>
   <name>Everything</name>
   <value>All </value>
   <valueClass></valueClass>
  </7>
</events>
</ScriptEventsManager>