3 Replies Latest reply on Aug 27, 2015 2:00 AM by clunty

    How can I find the target/result of a photoshop event?


      Hi all,


      Is there a method of retrieving information about the results of a Photoshop event? For example, after a Delete event ("Dlt ") can I get any information on what was deleted?

      Specifically my current needs are to find what layer was deleted after a delete event.


      The relevant js code in my project is:


      function registerPSEvent( typeIDs, clear ){
        // unregisters an even before adding it - prevents double events
        var regUnreg = null;
        if( clear ){
        console.log( 'Unregistering ' + typeIDs );
        regUnreg = 'PhotoshopUnRegisterEvent';
        } else {
        console.log( 'Registering ' + typeIDs );
        regUnreg = 'PhotoshopRegisterEvent';
        var e = new CSEvent(
        'com.adobe.' + regUnreg,
        e.data = typeIDs;
      // s2t is simply an abbreviation of stringIDToTypeID
      function addPSEventListener( typeStrings, callback, target ) {
        csInterface.evalScript( "s2t('"+typeStrings+"')", function(r){
        registerPSEvent( r, true );
        registerPSEvent( r );
        csInterface.addEventListener( 'PhotoshopCallback', callback.bind(target) );
        } );
      addPSEventListener( 'delete', delLayerEventHandler, this );
      delLayerEventHandler = function(e) {
        // here i would like to be able to get what was deleted





        • 1. Re: How can I find the target/result of a photoshop event?
          clunty Level 1

          I have found this post which seems to be able to achieve this by using app.notifier:

          Re: How to get event target?


          Ideally I would like to achieve this by using CSEvents

          • 2. Re: How can I find the target/result of a photoshop event?
            Pedro Cortez Marques Level 3

            Using javascript on CC2014


            //  to catch each one event (notifiers) properties, use this:
            for (var a=0; a<app.notifiers.length; a++) {
                var event_ = app.notifiers[a].event;
                var eventFile_ = app.notifiers[a].eventFile;
                var eventClass_ = app.notifiers[a].eventClass;
                // if you want to delete a specific one, reading 1,2 or 3 inner properties, use this:
                // if ([condition]) app.notifiers[a].remove();


            //~ // but you can remove all notifiers (events) at the same time like this

            //~ app.notifiers.removeAll();
            • 3. Re: How can I find the target/result of a photoshop event?
              clunty Level 1

              I've just discovered that when an event is received event.data holds 2 ints.

              I thought these 2 numbers were due to me using stringIDToTypeID rather than charIDToTypeID. However the second number is a way to access any attributes of the event. So I'm now using the below function to get info on the event:


              function get_event_descriptor( id ) {

                var desc = new ActionDescriptor();



                      var aref = desc.getReference(s2t('null'));      

                      var aref_obj = {

                          dclass : t2s( aref.getDesiredClass( s2t( 'null' ) ) ),

                          name : aref.getName(),

                          // id : aref.getContainer().getName()


                      return JSON.stringify( aref_obj );

                  } catch(e) {

                      //return false;

                      return JSON.stringify(e.message);




              id is the 2nd int returned in event.data.

              currently I've only dug around enough to ensure that the event paramater class is returned correctly but this is enough for my current needs.