21 Replies Latest reply on Jun 5, 2010 4:02 AM by c.pfaffenbichler

    what’s the notifier for starting the application

    c.pfaffenbichler Level 9

      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.

        • 1. Re: what’s the notifier for starting the application
          Michael L Hale Level 5

          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.

          • 2. Re: what’s the notifier for starting the application
            c.pfaffenbichler Level 9

            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?

            • 3. Re: what’s the notifier for starting the application
              Paul Riggott Level 6

              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>
              
              • 4. Re: what’s the notifier for starting the application
                c.pfaffenbichler Level 9

                Thanks.

                 

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

                • 5. Re: what’s the notifier for starting the application
                  Paul Riggott Level 6

                  Sorry Christoph, I have never used notifiers so can't answer.

                  • 6. Re: what’s the notifier for starting the application
                    Michael L Hale Level 5

                    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');

                    • 7. Re: what’s the notifier for starting the application
                      c.pfaffenbichler Level 9

                      Dang; do you remember where (in which of the guides) you picked that up?

                       

                      Thanks to you and Paul!

                      • 8. Re: what’s the notifier for starting the application
                        Michael L Hale Level 5

                        I didn't find that info in any guide. I just made a very simple script and set it to the start event. The script was...

                        $.level =1;
                        debugger;
                        

                        When I started Photoshop and the script opened in ESTK I typed the following in the console

                        arguments[0].count
                        Result: 3
                        typeIDToStringID(arguments[0].getKey(0))
                        Result: using
                        typeIDToStringID(arguments[0].getKey(1))
                        Result: what
                        typeIDToStringID(arguments[0].getKey(2))
                        Result: krenderFunction
                        

                        I then hit the run/contune button and when it stopped for the second time I type this into the console

                        typeIDToStringID(arguments[0].getKey(0))
                        Result: what
                        typeIDToStringID(arguments[0].getKey(1))
                        Error: General Photoshop error occurred. This functionality may not be available in this version of Photoshop.
                        - <no additional information available>
                        arguments[0].count
                        Result: 1
                        

                        As you can see the second time trying to get the second key throws an error so that is why I rechecked the count. As all we needed was a way to have the scirpt only run once I didn't bother exploring the keys.

                        1 person found this helpful
                        • 9. Re: what’s the notifier for starting the application
                          c.pfaffenbichler Level 9

                          Well … that would appear to be a bit over my head.

                           

                          Thanks again for taking the time to check it out!

                          • 10. Re: what’s the notifier for starting the application
                            habaki1 Level 1

                            Hello c.pfaffenbichler !

                             

                            You can use this script to display any events with all the arguments, and also to find out how to extract the data you want from events.

                            Just adjust the EventStNames and EventCharNames arrays to the lists of events you want to catch. And also the full path name of the script file.

                             

                            I also noticed that notify is called twice: The first time with 3 arguments and the second time with 1.

                            Now you can see it yourself.

                             

                            Note: Ignore the strange function that is automatically added at the beginning by the message editor. !!??

                            function(){return A.apply(null,[this].concat($A(arguments)))}

                             

                            /****************************************************
                              EVENT VIEWER
                            ****************************************************
                            Just execute the script to install it for wanted events.
                            BEWARE of PRINT : Bug in event manager
                            ****************************************************
                            30/05/2010 Habaki V1r02 : Add auto install
                            02/05/2010 Habaki V1r01 : Creation
                            ****************************************************/
                            var ScriptName = "Event Viewer, Habaki 2010";
                            var Verbose = 1;

                            // Events to catch ("All" for all)
                            var EventStNames = new Array("select", "open");
                            var EventCharNames = new Array('ntfy');

                            // Don't know yet how to get the file of the running script
                            var ScriptFilePath = "/c/photoshop/scripts/events/evtview.jsx";

                            var sTc = function(v) { return(app.typeIDToCharID(app.stringIDToTypeID(v)));};
                            /*--------------------------------------------------*
                            Num to String (enumeration value)
                            *--------------------------------------------------*/
                            function NumSt(Num)
                            {
                              var St = app.typeIDToStringID(Num);
                              if (St) return("\"" + St + "\"");
                              St = app.typeIDToCharID(Num);
                              if (St) return("'" + St + "'");
                              return(String(Num));
                            }
                            /*--------------------------------------------------*
                            ID to String
                            *--------------------------------------------------*/
                            function IDSt(ID)
                            {
                              var St = app.typeIDToStringID(ID);
                              if (St) return("\"" + St + "\"");
                              return("'" + app.typeIDToCharID(ID) + "'");
                            }
                            /*--------------------------------------------------*
                            Print Action Reference to string
                            *--------------------------------------------------*/
                            function AR_PrintSt(AR, Margin)
                            {
                              var St = Margin;
                              var Form;
                              var ValSt, FormSt, ValClass, ValClassc;
                             
                              AR.getName();
                              Form = AR.getForm();
                              ValClass = app.typeIDToStringID(AR.getDesiredClass());
                              ValClassc = app.typeIDToCharID(AR.getDesiredClass());
                             
                              if (Form == ReferenceFormType.CLASSTYPE) {
                                FormSt = "Class";
                                ValSt = ValClass;
                              }
                              else
                              if (Form == ReferenceFormType.ENUMERATED) {
                                FormSt = "Enumerated";
                                Type = AR.getEnumeratedType();
                                Val  = AR.getEnumeratedValue();
                                ValSt = "(Type=" + IDSt(Type)
                                      + ", Val=" + NumSt(Val)
                                      + ")";
                              }
                              else
                              if (Form == ReferenceFormType.IDENTIFIER) {
                                FormSt = "Identifier";
                                ValSt  = IDSt(AR.getIdentifier());
                              }
                              else
                              if (Form == ReferenceFormType.INDEX) {
                                FormSt = "Index";
                                ValSt  = String(AR.getIndex());
                              }
                              else
                              if (Form == ReferenceFormType.NAME) {
                                FormSt = "Name";
                                ValSt = "\"" + AR.getName() + "\"";
                              }
                              else
                              if (Form == ReferenceFormType.OFFSET) {
                                FormSt = "Offset";
                                ValSt = String(AR.getOffset());
                              }
                              else
                              if (Form == ReferenceFormType.PROPERTY) {
                                FormSt = "Property";
                                ValSt = IDSt(AR.getProperty());
                              }
                              else {
                                FormSt = "??";
                                ValSt = "??";
                              }
                             
                              St += "Class=" + ValClass
                                 //+ "('" + ValClassc + "')" // CharID
                                 + ", " + FormSt + "=" + ValSt
                                 ;
                              return(St);
                            }
                            /*--------------------------------------------------*
                            Print Descriptor to string
                            *--------------------------------------------------*/
                            function DS_PrintSt(DS, Key, Margin)
                            {
                              var Val;
                              var TypeSt = "?";
                              var ValSt = "?";
                              var Type = DS.getType(Key);
                             
                              if (Type == DescValueType.ALIASTYPE) {
                                TypeSt = "Path";
                                ValSt = DS.getPath(Key);
                              }
                              else
                              if (Type == DescValueType.BOOLEANTYPE) {
                                TypeSt = "Boolean";
                                ValSt = DS.getBoolean(Key);
                              }
                              else
                              if (Type == DescValueType.CLASSTYPE) {
                                TypeSt = "Class";
                                Type = DS.getClass(Key);
                                ValSt = IDSt(Type);
                              }
                              else
                              if (Type == DescValueType.DOUBLETYPE) {
                                TypeSt = "Double";
                                ValSt = String(DS.getDouble(Key));
                              }
                              else
                              if (Type == DescValueType.ENUMERATEDTYPE) {
                                TypeSt = "Enumerated";
                                Type = DS.getEnumerationType(Key);
                                Val  = DS.getEnumerationValue(Key);
                                ValSt = "Type=" + IDSt(Type)
                                      + ", Val=" + NumSt(Val)
                                      ;
                              }
                              else
                              if (Type == DescValueType.INTEGERTYPE) {
                                TypeSt = "Integer";
                                ValSt = String(DS.getInteger(Key));
                              }
                              else
                              if (Type == DescValueType.LISTTYPE) {
                                TypeSt = "List";
                                Val = DS.getList(Key);
                                ValSt = "\r"
                                      + AL_PrintSt(Val, Margin + "    ")
                                      ;
                              }
                              else
                              if (Type == DescValueType.OBJECTTYPE) {
                                TypeSt = "Object";
                                Type = DS.getObjectType(Key);
                                Val = DS.getObjectValue(Key);
                                ValSt = "Type=" + IDSt(Type) + ",\r"
                                      + AD_PrintSt(Val, Margin + "    ")
                                      ;
                              }
                              else
                              if (Type == DescValueType.RAWTYPE) {
                                TypeSt = "Raw";
                                ValSt = DS.getData(Key);
                                //ValSt = "Len="+ ValSt.length + ", Data={" + DS.getData(Key) + "}";
                                ValSt = "Len="+ ValSt.length + ", Data={" + "..." + "}";
                              }
                              else
                              if (Type == DescValueType.REFERENCETYPE) {
                                TypeSt = "Reference";
                                Val = DS.getReference(Key);
                                ValSt = AR_PrintSt(Val, "");
                              }
                              else
                              if (Type == DescValueType.STRINGTYPE) {
                                TypeSt = "String";
                                ValSt = "\"" + DS.getString(Key) + "\"";
                              }
                              else
                              if (Type == DescValueType.UNITDOUBLE) {
                                TypeSt = "UnitDouble";
                                Type = DS.getUnitDoubleType(Key);
                                ValSt = "Type=" + IDSt(Type)
                                      + ", Val=" + String(DS.getUnitDoubleValue(Key))
                                      ;
                              }
                              else {
                                TypeSt = "Type";
                                ValSt = DS.getType(Key);
                              }
                              return(TypeSt + "(" + ValSt + ")");
                            }
                            /*--------------------------------------------------*
                            Print Action List to string
                            *--------------------------------------------------*/
                            function AL_PrintSt(AL, Margin)
                            {
                              var Key;
                              var St = "";
                             
                              for (Key=0;Key < AL.count; Key++) {
                                St += Margin + "[" + String(Key) + "]:"
                                    + DS_PrintSt(AL, Key, Margin)
                                    ;
                                if (Key == AL.count-1) St += "\r";
                                else                   St += ",\r"
                              } // for
                              St += Margin;
                              return(St);
                            }
                            /*--------------------------------------------------*
                            Print Action Descriptor to string
                            *--------------------------------------------------*/
                            function AD_PrintSt(AD, Margin)
                            {
                              var i;
                              var St = "";
                              var Key;
                             
                              for (i=0;i < AD.count; i++) {
                                Key  = AD.getKey(i);
                                St += Margin + "Key[" + String(i) + "]:" + IDSt(Key)
                                   + " = "
                                   + DS_PrintSt(AD, Key, Margin)
                                   ;
                                if (i == AD.count-1) St += "\r";
                                else                 St += ",\r"
                              } // for
                              St += Margin;
                              return(St);
                            }
                            /*--------------------------------------------------*
                               Parse an event
                            arguments[0] : ActionDescriptor
                            arguments[1] : Event typeID
                            arguments[2..] : ?
                            *--------------------------------------------------*/
                            try {
                              if (arguments.length < 2) {
                                //alert("arguments.length=" + arguments.length, ScriptName);
                                alert("INSTALLATION", ScriptName);
                                app.notifersEnabled = true;
                                try{
                                  app.notifiers.removeAll;
                                  for (i=0;i < EventStNames.length; i++) {
                                    app.notifiers.add(sTc(EventStNames[i]), new File(ScriptFilePath));
                                  }
                                  for (i=0;i < EventCharNames.length; i++) {
                                    app.notifiers.add(EventCharNames[i], new File(ScriptFilePath));
                                  }
                                } catch (e) {}
                                throw(0);
                              }
                             
                              var AD        = arguments[0];
                              var EventName = app.typeIDToStringID(arguments[1]);
                              var St;
                             
                              St = EventName + " \r";
                              St += AD_PrintSt(AD, "");
                              // Other args
                              for (i=2;i < arguments.length; i++){
                                St += "Arg[" + String(i) + "]=" + String(arguments[i]);
                              }
                             
                              if (Verbose) alert(St, ScriptName);
                             
                            } catch(ex) {
                              if (ex) alert(ex.message, ScriptName)
                            }
                            /*--------------------------------------------------*/

                            1 person found this helpful
                            • 11. Re: what’s the notifier for starting the application
                              c.pfaffenbichler Level 9

                              Thanks; I get an alert »arguments is undefined«.

                              • 12. Re: what’s the notifier for starting the application
                                habaki1 Level 1

                                Hello !

                                 

                                I read back the script from my post and alert gives correct messages.

                                 

                                When started the alert: "INSTALLATION" is displayed. Then alerts are displayed for every listed events in the EventXXXNames arrays.

                                The script checks first an array of arguments: arguments.

                                It seems that this array is not defined when you call the script from the PS menu (but it is for me (PS4 on windows)).

                                So add a line after try{ to ignore this case.

                                 

                                I use this script daily on all sorts of events and it seems ok so far.

                                 

                                I just added the EventCharNames array for you because you use charIDs like 'Ntfy' but i wrote 'ntfy'.

                                Sorry for that.

                                • 13. Re: what’s the notifier for starting the application
                                  habaki1 Level 1

                                  I forgot to give the exact modification:

                                   

                                  It is faster to correct the script if already copied, but here is is the whole script with the correction.

                                   

                                   

                                  /****************************************************
                                    EVENT VIEWER
                                  ****************************************************
                                  Just execute the script to install it for wanted events.
                                  BEWARE of PRINT : Bug in event manager
                                  ****************************************************
                                  04/06/2010 Habaki V1r02b: Fix Pb on undefined arguments
                                  30/05/2010 Habaki V1r02 : Add auto install
                                  02/05/2010 Habaki V1r01 : Creation
                                  ****************************************************/
                                  var ScriptName = "Event Viewer, Habaki 2010";
                                  var Verbose = 1;

                                  // Events to catch
                                  var EventStNames = new Array("select", "open");
                                  var EventCharNames = new Array('Ntfy');

                                  // Don't know yet how to get the file of the running script
                                  var ScriptFilePath = "/c/images/photoshop/scripts/events/evtview.jsx";

                                  var sTc = function(v) { return(app.typeIDToCharID(app.stringIDToTypeID(v)));};
                                  /*--------------------------------------------------*
                                  Num to String (enumeration value)
                                  *--------------------------------------------------*/
                                  function NumSt(Num)
                                  {
                                    var St = app.typeIDToStringID(Num);
                                    if (St) return("\"" + St + "\"");
                                    St = app.typeIDToCharID(Num);
                                    if (St) return("'" + St + "'");
                                    return(String(Num));
                                  }
                                  /*--------------------------------------------------*
                                  ID to String
                                  *--------------------------------------------------*/
                                  function IDSt(ID)
                                  {
                                    var St = app.typeIDToStringID(ID);
                                    if (St) return("\"" + St + "\"");
                                    return("'" + app.typeIDToCharID(ID) + "'");
                                  }
                                  /*--------------------------------------------------*
                                  Print Action Reference to string
                                  *--------------------------------------------------*/
                                  function AR_PrintSt(AR, Margin)
                                  {
                                    var St = Margin;
                                    var Form;
                                    var ValSt, FormSt, ValClass, ValClassc;
                                   
                                    AR.getName();
                                    Form = AR.getForm();
                                    ValClass = app.typeIDToStringID(AR.getDesiredClass());
                                    ValClassc = app.typeIDToCharID(AR.getDesiredClass());
                                   
                                    if (Form == ReferenceFormType.CLASSTYPE) {
                                      FormSt = "Class";
                                      ValSt = ValClass;
                                    }
                                    else
                                    if (Form == ReferenceFormType.ENUMERATED) {
                                      FormSt = "Enumerated";
                                      Type = AR.getEnumeratedType();
                                      Val  = AR.getEnumeratedValue();
                                      ValSt = "(Type=" + IDSt(Type)
                                            + ", Val=" + NumSt(Val)
                                            + ")";
                                    }
                                    else
                                    if (Form == ReferenceFormType.IDENTIFIER) {
                                      FormSt = "Identifier";
                                      ValSt  = IDSt(AR.getIdentifier());
                                    }
                                    else
                                    if (Form == ReferenceFormType.INDEX) {
                                      FormSt = "Index";
                                      ValSt  = String(AR.getIndex());
                                    }
                                    else
                                    if (Form == ReferenceFormType.NAME) {
                                      FormSt = "Name";
                                      ValSt = "\"" + AR.getName() + "\"";
                                    }
                                    else
                                    if (Form == ReferenceFormType.OFFSET) {
                                      FormSt = "Offset";
                                      ValSt = String(AR.getOffset());
                                    }
                                    else
                                    if (Form == ReferenceFormType.PROPERTY) {
                                      FormSt = "Property";
                                      ValSt = IDSt(AR.getProperty());
                                    }
                                    else {
                                      FormSt = "??";
                                      ValSt = "??";
                                    }
                                   
                                    St += "Class=" + ValClass
                                       //+ "('" + ValClassc + "')" // CharID
                                       + ", " + FormSt + "=" + ValSt
                                       ;
                                    return(St);
                                  }
                                  /*--------------------------------------------------*
                                  Print Descriptor to string
                                  *--------------------------------------------------*/
                                  function DS_PrintSt(DS, Key, Margin)
                                  {
                                    var Val;
                                    var TypeSt = "?";
                                    var ValSt = "?";
                                    var Type = DS.getType(Key);
                                   
                                    if (Type == DescValueType.ALIASTYPE) {
                                      TypeSt = "Path";
                                      ValSt = DS.getPath(Key);
                                    }
                                    else
                                    if (Type == DescValueType.BOOLEANTYPE) {
                                      TypeSt = "Boolean";
                                      ValSt = DS.getBoolean(Key);
                                    }
                                    else
                                    if (Type == DescValueType.CLASSTYPE) {
                                      TypeSt = "Class";
                                      Type = DS.getClass(Key);
                                      ValSt = IDSt(Type);
                                    }
                                    else
                                    if (Type == DescValueType.DOUBLETYPE) {
                                      TypeSt = "Double";
                                      ValSt = String(DS.getDouble(Key));
                                    }
                                    else
                                    if (Type == DescValueType.ENUMERATEDTYPE) {
                                      TypeSt = "Enumerated";
                                      Type = DS.getEnumerationType(Key);
                                      Val  = DS.getEnumerationValue(Key);
                                      ValSt = "Type=" + IDSt(Type)
                                            + ", Val=" + NumSt(Val)
                                            ;
                                    }
                                    else
                                    if (Type == DescValueType.INTEGERTYPE) {
                                      TypeSt = "Integer";
                                      ValSt = String(DS.getInteger(Key));
                                    }
                                    else
                                    if (Type == DescValueType.LISTTYPE) {
                                      TypeSt = "List";
                                      Val = DS.getList(Key);
                                      ValSt = "\r"
                                            + AL_PrintSt(Val, Margin + "    ")
                                            ;
                                    }
                                    else
                                    if (Type == DescValueType.OBJECTTYPE) {
                                      TypeSt = "Object";
                                      Type = DS.getObjectType(Key);
                                      Val = DS.getObjectValue(Key);
                                      ValSt = "Type=" + IDSt(Type) + ",\r"
                                            + AD_PrintSt(Val, Margin + "    ")
                                            ;
                                    }
                                    else
                                    if (Type == DescValueType.RAWTYPE) {
                                      TypeSt = "Raw";
                                      ValSt = DS.getData(Key);
                                      //ValSt = "Len="+ ValSt.length + ", Data={" + DS.getData(Key) + "}";
                                      ValSt = "Len="+ ValSt.length + ", Data={" + "..." + "}";
                                    }
                                    else
                                    if (Type == DescValueType.REFERENCETYPE) {
                                      TypeSt = "Reference";
                                      Val = DS.getReference(Key);
                                      ValSt = AR_PrintSt(Val, "");
                                    }
                                    else
                                    if (Type == DescValueType.STRINGTYPE) {
                                      TypeSt = "String";
                                      ValSt = "\"" + DS.getString(Key) + "\"";
                                    }
                                    else
                                    if (Type == DescValueType.UNITDOUBLE) {
                                      TypeSt = "UnitDouble";
                                      Type = DS.getUnitDoubleType(Key);
                                      ValSt = "Type=" + IDSt(Type)
                                            + ", Val=" + String(DS.getUnitDoubleValue(Key))
                                            ;
                                    }
                                    else {
                                      TypeSt = "Type";
                                      ValSt = DS.getType(Key);
                                    }
                                    return(TypeSt + "(" + ValSt + ")");
                                  }
                                  /*--------------------------------------------------*
                                  Print Action List to string
                                  *--------------------------------------------------*/
                                  function AL_PrintSt(AL, Margin)
                                  {
                                    var Key;
                                    var St = "";
                                   
                                    for (Key=0;Key < AL.count; Key++) {
                                      St += Margin + "[" + String(Key) + "]:"
                                          + DS_PrintSt(AL, Key, Margin)
                                          ;
                                      if (Key == AL.count-1) St += "\r";
                                      else                   St += ",\r"
                                    } // for
                                    St += Margin;
                                    return(St);
                                  }
                                  /*--------------------------------------------------*
                                  Print Action Descriptor to string
                                  *--------------------------------------------------*/
                                  function AD_PrintSt(AD, Margin)
                                  {
                                    var i;
                                    var St = "";
                                    var Key;
                                   
                                    for (i=0;i < AD.count; i++) {
                                      Key  = AD.getKey(i);
                                      St += Margin + "Key[" + String(i) + "]:" + IDSt(Key)
                                         + " = "
                                         + DS_PrintSt(AD, Key, Margin)
                                         ;
                                      if (i == AD.count-1) St += "\r";
                                      else                 St += ",\r"
                                    } // for
                                    St += Margin;
                                    return(St);
                                  }
                                  /*--------------------------------------------------*
                                     Parse an event
                                  arguments[0] : ActionDescriptor
                                  arguments[1] : Event typeID
                                  arguments[2..] : ?
                                  *--------------------------------------------------*/
                                  try {

                                    var nd = 0;
                                    try{ arguments } catch (e) {nd = 1;}
                                    if (nd  || arguments.length < 2) {
                                      //alert("arguments.length=" + arguments.length, ScriptName);
                                      alert("INSTALLATION", ScriptName);
                                      app.notifiersEnabled = true;
                                      try{
                                        app.notifiers.removeAll();
                                        for (i=0;i < EventStNames.length; i++) {
                                          app.notifiers.add(sTc(EventStNames[i]), new File(ScriptFilePath));
                                        }
                                        for (i=0;i < EventCharNames.length; i++) {
                                          app.notifiers.add(EventCharNames[i], new File(ScriptFilePath));
                                        }
                                      } catch (e) {}
                                      throw(0);
                                    }
                                   
                                    var AD        = arguments[0];
                                    var EventName = app.typeIDToStringID(arguments[1]);
                                    var St;
                                   
                                    St = EventName + " \r";
                                    St += AD_PrintSt(AD, "");
                                    // Other args
                                    for (i=2;i < arguments.length; i++){
                                      St += "Arg[" + String(i) + "]=" + String(arguments[i]);
                                    }
                                   
                                    if (Verbose) alert(St, ScriptName);
                                   
                                  } catch(ex) {
                                    if (ex) alert(ex.message, ScriptName)
                                  }
                                  /*--------------------------------------------------*/

                                  • 14. Re: what’s the notifier for starting the application
                                    Paul Riggott Level 6

                                    This may be of use..

                                    // Don't know yet how to get the file of the running script
                                    var ScriptFilePath = new File($.fileName);
                                    //var ScriptFilePath = "/c/images/photoshop/scripts/events/evtview.jsx";
                                    
                                    • 15. Re: what’s the notifier for starting the application
                                      habaki1 Level 1

                                      Thanks Paul.

                                       

                                      I will have a look at $.

                                      • 16. Re: what’s the notifier for starting the application
                                        Tom Ruark Adobe Employee

                                        Here is some C code that I added to ScriptingSupport to get around the 'double' event for first launch bug that was in CS4. You could convert that to JavaScript or use one of the solutions already mentioned in this thread. (And the reason we are sending two.)

                                         

                                        /* refix for 2386218, with that fix you only get one event but if you register

                                        two notifiers for the same event you only get one of them during startup

                                        photoshop sends two Ntfy events, one for T3DTool::StartRenderDevicePlugins and one for enumFirstIdle

                                        we only want to allow enumFirstIdle Ntfy event to get processed */

                                        bool

                                         

                                         

                                        PSFirstIdle( DescriptorEventID event, PIActionDescriptor descriptor )

                                        {

                                         

                                        if ( eventNotify != event ) return true;

                                        Boolean hasKey =

                                        false;

                                        CPsSuite::PsActionDescriptor->HasKey( descriptor, keyWhat, &hasKey );

                                         

                                        if ( hasKey )

                                        {

                                        DescriptorEnumID result = 0;

                                        DescriptorEnumTypeID type = 0;

                                        CPsSuite::PsActionDescriptor->GetEnumerated( descriptor, keyWhat, &type, &result );

                                         

                                        if ( result == enumFirstIdle && type == typeNotify ) return true;

                                        }

                                         

                                        return false;

                                        }

                                         

                                        • 17. Re: what’s the notifier for starting the application
                                          c.pfaffenbichler Level 9

                                          Thanks, Habaki!

                                          I’ll try the amended Script.

                                          But as a Mac-User I guess I have to make some edits anyhow. 

                                          • 18. Re: what’s the notifier for starting the application
                                            c.pfaffenbichler Level 9

                                            Thanks, Tom, but I neither understand where I could put that code usefully nor how to convert it to JavaScript – I’m more of a Scripting-lightweight.

                                             

                                            But Michael’s check (if( arguments[0].count == 1) ) works fine, so the problem is solved anyway.

                                            • 19. Re: what’s the notifier for starting the application
                                              c.pfaffenbichler Level 9

                                              Thanks, Paul, with your ScriptFilePath-proposal the Mac-thing was taken care of and now it works on my machine, too.

                                               

                                              Thanks again, Habaki.

                                              • 20. Re: what’s the notifier for starting the application
                                                Michael L Hale Level 5

                                                If I understand Tom's code, it is checking the value in the descriptor key 'what' and returning true if it matches the value that should be there in the second event. Although my check works now Tom's is a better check. Here is how I would convert that to javascirpt.

                                                 

                                                if( arguments[0].hasKey(stringIDToTypeID('what')) ){
                                                     if(arguments[0].getEnumerationValue(stringIDToTypeID('what')) == charIDToTypeID('FrId')){
                                                          alert('second event - app finished loading');
                                                          // your event script here
                                                     }
                                                }
                                                
                                                • 21. Re: what’s the notifier for starting the application
                                                  c.pfaffenbichler Level 9

                                                  Well, unfortunately I’m out of »Helpful« and »Correct«-markers …

                                                  Thanks some more to Tom and Michael!