Skip to content

Instantly share code, notes, and snippets.

@alagu
Last active Aug 29, 2015
Embed
What would you like to do?

Capturing Events

Install ScriptListener Plugin plugin

Short tutorial

You'd find logs in ScriptingListenerJS.log like this

  // =======================================================
  var idShw = charIDToTypeID( "Shw " );
      var desc245 = new ActionDescriptor();
      var idnull = charIDToTypeID( "null" );
          var list22 = new ActionList();
              var ref134 = new ActionReference();
              var idLyr = charIDToTypeID( "Lyr " );
              ref134.putName( idLyr, "Layer 1" );
          list22.putReference( ref134 );
      desc245.putList( idnull, list22 );
  executeAction( idShw, desc245, DialogModes.NO );

Slicing

When I tried out slicing:

// =======================================================
var idslct = charIDToTypeID( "slct" );
    var desc2 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idsliceTool = stringIDToTypeID( "sliceTool" );
        ref1.putClass( idsliceTool );
    desc2.putReference( idnull, ref1 );
    var iddontRecord = stringIDToTypeID( "dontRecord" );
    desc2.putBoolean( iddontRecord, true );
    var idforceNotify = stringIDToTypeID( "forceNotify" );
    desc2.putBoolean( idforceNotify, true );
executeAction( idslct, desc2, DialogModes.NO );

Also - it has information on coordinates:

 var idUsng = charIDToTypeID( "Usng" );
        var desc4 = new ActionDescriptor();
        var idType = charIDToTypeID( "Type" );
        var idsliceType = stringIDToTypeID( "sliceType" );
        var iduser = stringIDToTypeID( "user" );
        desc4.putEnumerated( idType, idsliceType, iduser );
        var idAt = charIDToTypeID( "At  " );
            var desc5 = new ActionDescriptor();
            var idTop = charIDToTypeID( "Top " );
            var idRlt = charIDToTypeID( "#Rlt" );
            desc5.putUnitDouble( idTop, idRlt, 89.500000 );
            var idLeft = charIDToTypeID( "Left" );
            var idRlt = charIDToTypeID( "#Rlt" );
            desc5.putUnitDouble( idLeft, idRlt, 20.000000 );
            var idBtom = charIDToTypeID( "Btom" );
            var idRlt = charIDToTypeID( "#Rlt" );
            desc5.putUnitDouble( idBtom, idRlt, 223.500000 );
            var idRght = charIDToTypeID( "Rght" );
            var idRlt = charIDToTypeID( "#Rlt" );
            desc5.putUnitDouble( idRght, idRlt, 120.000000 );

"Btom", "Top " represents the top and bottom co-ordinates.

With some googling, some pointers [1]

Helper Libraries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment