Skip to main content
Inspiring
October 25, 2014
Question

optimizing script-listener code

  • October 25, 2014
  • 2 replies
  • 1649 views

I have noticed in some threads that the script listener action manager code is modified.

Is there a method  to modify the script-listener/action manager code?

How ca interpret the script-listener action manager syntax?

This topic has been closed for replies.

2 replies

Kukurykus
Legend
March 11, 2018

I was asked today of my script that modify SL AM code, so if anyone else had similar question here is a link to that script:

https://www.ps-scripts.com/viewtopic.php?f=51&t=24469&sid=3ddff9139a9a3b61d3a9ebab96d707e9

Inspiring
October 25, 2014

There is a script in xtools called LastLogEntry.jsx

http://ps-scripts.cvs.sourceforge.net/viewvc/ps-scripts/xtools/apps/LastLogEntry.jsx

This script will retrieve the last entry in the ScriptingListener log file and put it in a ScriptUI dialog. You can copy the

contents to a jsx file at this point. However, there is a magic 'Fix' button that converts the layout of the code into

a much more readable format.

Here's an example before Fix:

var idMk = charIDToTypeID( "Mk  " );

    var desc1 = new ActionDescriptor();

    var idNw = charIDToTypeID( "Nw  " );

        var desc2 = new ActionDescriptor();

        var idMd = charIDToTypeID( "Md  " );

        var idRGBM = charIDToTypeID( "RGBM" );

        desc2.putClass( idMd, idRGBM );

        var idWdth = charIDToTypeID( "Wdth" );

        var idRlt = charIDToTypeID( "#Rlt" );

        desc2.putUnitDouble( idWdth, idRlt, 360.000000 );

        var idHght = charIDToTypeID( "Hght" );

        var idRlt = charIDToTypeID( "#Rlt" );

        desc2.putUnitDouble( idHght, idRlt, 504.000000 );

        var idRslt = charIDToTypeID( "Rslt" );

        var idRsl = charIDToTypeID( "#Rsl" );

        desc2.putUnitDouble( idRslt, idRsl, 300.000000 );

        var idpixelScaleFactor = stringIDToTypeID( "pixelScaleFactor" );

        desc2.putDouble( idpixelScaleFactor, 1.000000 );

        var idFl = charIDToTypeID( "Fl  " );

        var idFl = charIDToTypeID( "Fl  " );

        var idWht = charIDToTypeID( "Wht " );

        desc2.putEnumerated( idFl, idFl, idWht );

        var idDpth = charIDToTypeID( "Dpth" );

        desc2.putInteger( idDpth, 8 );

        var idprofile = stringIDToTypeID( "profile" );

        desc2.putString( idprofile, """ProPhoto RGB""" );

    var idDcmn = charIDToTypeID( "Dcmn" );

    desc1.putObject( idNw, idDcmn, desc2 );

executeAction( idMk, desc1, DialogModes.NO );

And here's the result after fix:

//
// Generated from ~/AppData/Local/Temp/tmp00000001 on Sat Oct 25 2014 15:42:43 GMT-0500
//

function ftn1() {
  function cTID(s) { return app.charIDToTypeID(s); };
  function sTID(s) { return app.stringIDToTypeID(s); };

    var desc1 = new ActionDescriptor();
        var desc2 = new ActionDescriptor();
        desc2.putClass( cTID('Md  '), cTID('RGBM') );
        desc2.putUnitDouble( cTID('Wdth'), cTID('#Rlt'), 360.000000 );
        desc2.putUnitDouble( cTID('Hght'), cTID('#Rlt'), 504.000000 );
        desc2.putUnitDouble( cTID('Rslt'), cTID('#Rsl'), 300.000000 );
        desc2.putDouble( sTID('pixelScaleFactor'), 1.000000 );
        desc2.putEnumerated( cTID('Fl  '), cTID('Fl  '), cTID('Wht ') );
        desc2.putInteger( cTID('Dpth'), 8 );
        desc2.putString( sTID('profile'), """ProPhoto RGB""" );
    desc1.putObject( cTID('Nw  '), cTID('Dcmn'), desc2 );
    executeAction( cTID('Mk  '), desc1, DialogModes.NO );
};

Much more concise. There is one possible problem. The """ProPhoto RGB""" should really be modified to "ProPhoto RGB". I have no idea what the extra ""s are doing there. It seems to parse OK in PS/JS but throws a syntax error in Firefox. As far as being able to read this, the function  is going to make('Mk  ') a new('Nw  ') document('Dcmn') with

an initial set of attributes. You could replace the specific attributes will function arguments that are passed in. And

you would probably want to change the function name.

[Edited for code formatting.]

ojodegatoAuthor
Inspiring
October 25, 2014

That's oool script, that is fascinating.

Thanks!