• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
5

Clean SL

Advocate ,
Sep 07, 2017 Sep 07, 2017

Copy link to clipboard

Copied

Hello gang!

I just wanted to share with you my small utility tool for Photoshop called Clean SL that cleans ScriptingListenerJS.log file to make it more readable.

Recently watched Davide_Barranca​'s Adobe Photoshop HTML Panels Development course  and realised how painful it is to work with Action Manager's code and how unreadable it is right off the box. I know there are quite a few other tools that cleans log file, however it doesn't hurt to have an option to choose.

Interested? Grab it here: rendertom / Clean SL / source / — Bitbucket

Clean SL.png

Script performs multiple actions such as cleaning-up variable names and hoisting them to the top, wraps code block into function, converts charID to string ID for better readability and such. Resulting code is clean and maintains better readability.

Features:

  • Load entire ScriptingListenerJS.log content
  • Load only last entry in ScriptingListenerJS.log
  • Enter ScriptingListenerJS code manually

Options:

  • Hoist variable declaration to the top
  • Consolidate variables
  • Give descriptive variable names
  • Convert charID to stringID for better readability
  • Replace stringIDToTypeID() to s2t() function
  • Wrap to function block.

Example:

From this:

var idHStr = charIDToTypeID( "HStr" );

    var desc21 = new ActionDescriptor();

    var idpresetKind = stringIDToTypeID( "presetKind" );

    var idpresetKindType = stringIDToTypeID( "presetKindType" );

    var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );

    desc21.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );

    var idClrz = charIDToTypeID( "Clrz" );

    desc21.putBoolean( idClrz, false );

    var idAdjs = charIDToTypeID( "Adjs" );

        var list1 = new ActionList();

            var desc22 = new ActionDescriptor();

            var idH = charIDToTypeID( "H   " );

            desc22.putInteger( idH, 39 );

            var idStrt = charIDToTypeID( "Strt" );

            desc22.putInteger( idStrt, 23 );

            var idLght = charIDToTypeID( "Lght" );

            desc22.putInteger( idLght, -27 );

        var idHsttwo = charIDToTypeID( "Hst2" );

        list1.putObject( idHsttwo, desc22 );

    desc21.putList( idAdjs, list1 );

executeAction( idHStr, desc21, DialogModes.NO );

to this:

hueSaturation();

function hueSaturation() {

    var s2t = function (s) {

        return app.stringIDToTypeID(s);

    };

    var descriptor = new ActionDescriptor();

    var list = new ActionList();

    var descriptor2 = new ActionDescriptor();

    descriptor.putEnumerated( s2t( "presetKind" ), s2t( "presetKindType" ), s2t( "presetKindCustom" ));

    descriptor.putBoolean( s2t( "colorize" ), false );

    descriptor2.putInteger( s2t( "hue" ), 39 );

    descriptor2.putInteger( s2t( "saturation" ), 23 );

    descriptor2.putInteger( s2t( "lightness" ), -27 );

    list.putObject( s2t( "hueSatAdjustmentV2" ), descriptor2 );

    descriptor.putList( s2t( "adjustment" ), list );

    executeAction( s2t( "hueSaturation" ), descriptor, DialogModes.NO );

}

Installation

Clone or download repository and place Clean SJ.jsx script to Photoshop’s Scripts folder:

Adobe Photoshop CC 20XX -> Presets -> Scripts -> Clean JS.jsx

Restart Photoshop to access Clean JS script from File -> Scripts

------------------------------------------------

Since I am rather new to Photoshop Scripting, I might have missed something of my code brakes. So if you find any bugs or issues, please do not hesitate to let me know so I could fix it.

So, happy cleaning everybody!

TOPICS
Actions and scripting

Views

14.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
replies 131 Replies 131
Community Expert ,
Sep 07, 2017 Sep 07, 2017

Copy link to clipboard

Copied

I downloaded it and it look very interesting.  It work somewhat but I have big problems with it.  I control the script listener log with a bat file so I can know what is in the log. If did a simple test.  I cleared the log. I the use the new file new interface to created a new document added a shape layer then add a layer style toe the shape layer.  I then lock the log by changing it to read only.  I look at the log a saw some junk action manager steps then saw the make document make shape and add layer style.

I then started up Clean SL.  It display the make document source code. Not any of the junk steps. I could evaluate the source clean the source and evaluate the clean source.

I the loaded the  full log. the UI showed all the steps in the log including the first few unknown steps.  Cloud not evaluate the source. Through and error. So I unlocked the log and deleted  the few junk steps saved the log and locked it. 

Clean SL could then evaluate the source  and clean the source but when I evaluated the cleaned output a new document was not created and the shape layer was added the the document create evaluating the source. The layer style was also added.

When I close Clean SL and close the document and started Clean SL load the log and cleaned the source when I tried the evaluate the cleaned code the was an error.

Capture.jpg

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 07, 2017 Sep 07, 2017

Copy link to clipboard

Copied

JJMack Sorry, I have trouble understanding you, maybe because English is not our native language ...

Do you mind providing Action Managers code, so I could test?

Also, I didn't think one would use Clean SL to clean entire log file and try to execute it. However, this would be possible. I would have to increment function names as well, because if you took a look at Clean SL code, it creates function make() few times. This might be the issue for your problem.

If you provided source code, I could look into that.

Thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 07, 2017 Sep 07, 2017

Copy link to clipboard

Copied

Before:

var idsave = charIDToTypeID( "save" );

    var desc8 = new ActionDescriptor();

    var idAs = charIDToTypeID( "As  " );

        var desc9 = new ActionDescriptor();

        var idPGIT = charIDToTypeID( "PGIT" );

        var idPGIT = charIDToTypeID( "PGIT" );

        var idPGIN = charIDToTypeID( "PGIN" );

        desc9.putEnumerated( idPGIT, idPGIT, idPGIN );

        var idPNGf = charIDToTypeID( "PNGf" );

        var idPNGf = charIDToTypeID( "PNGf" );

        var idPGAd = charIDToTypeID( "PGAd" );

        desc9.putEnumerated( idPNGf, idPNGf, idPGAd );

        var idCmpr = charIDToTypeID( "Cmpr" );

        desc9.putInteger( idCmpr, 9 );

    var idPNGF = charIDToTypeID( "PNGF" );

    desc8.putObject( idAs, idPNGF, desc9 );

    var idIn = charIDToTypeID( "In  " );

    desc8.putPath( idIn, new File( "C:\\Users\\Eu\\Desktop\\Img.png" ) );

    var idDocI = charIDToTypeID( "DocI" );

    desc8.putInteger( idDocI, 279 );

    var idsaveStage = stringIDToTypeID( "saveStage" );

    var idsaveStageType = stringIDToTypeID( "saveStageType" );

    var idsaveSucceeded = stringIDToTypeID( "saveSucceeded" );

    desc8.putEnumerated( idsaveStage, idsaveStageType, idsaveSucceeded );

executeAction( idsave, desc8, DialogModes.NO );

After

save();

function save() {

    var s2t = function(s) {

        return app.stringIDToTypeID(s);

    };

    var descriptor = new ActionDescriptor();

    var descriptor2 = new ActionDescriptor();

    descriptor2.putEnumerated(s2t("PNGInterlaceType"), s2t("PNGInterlaceType"), s2t("PNGInterlaceNone"));

    descriptor2.putEnumerated(s2t("PNGFilter"), s2t("PNGFilter"), s2t("PNGFilterAdaptive"));

    descriptor2.putInteger(s2t("compression"), 9);

    descriptor.putObject(s2t("as"), s2t("PNGFormat"), descriptor2);

    descriptor.putPath(s2t("in"), new File("C:\\Users\\Eu\\Desktop\\Img.png"));

    descriptor.putInteger(s2t("documentID"), 279);

    descriptor.putEnumerated(s2t("saveStage"), s2t("saveStageType"), s2t("saveSucceeded"));

    executeAction(s2t("save"), descriptor, DialogModes.NO);

}

Very good! Congratulations on the script, nice work.

Tomas Sinkunas,thanks for sharing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 07, 2017 Sep 07, 2017

Copy link to clipboard

Copied

// =======================================================

var idMk = charIDToTypeID( "Mk  " );

    var desc5 = new ActionDescriptor();

    var idNw = charIDToTypeID( "Nw  " );

        var desc6 = new ActionDescriptor();

        var idartboard = stringIDToTypeID( "artboard" );

        desc6.putBoolean( idartboard, false );

        var idMd = charIDToTypeID( "Md  " );

        var idRGBM = charIDToTypeID( "RGBM" );

        desc6.putClass( idMd, idRGBM );

        var idWdth = charIDToTypeID( "Wdth" );

        var idRlt = charIDToTypeID( "#Rlt" );

        desc6.putUnitDouble( idWdth, idRlt, 504.000000 );

        var idHght = charIDToTypeID( "Hght" );

        var idRlt = charIDToTypeID( "#Rlt" );

        desc6.putUnitDouble( idHght, idRlt, 360.000000 );

        var idRslt = charIDToTypeID( "Rslt" );

        var idRsl = charIDToTypeID( "#Rsl" );

        desc6.putUnitDouble( idRslt, idRsl, 100.000000 );

        var idpixelScaleFactor = stringIDToTypeID( "pixelScaleFactor" );

        desc6.putDouble( idpixelScaleFactor, 1.000000 );

        var idFl = charIDToTypeID( "Fl  " );

        var idFl = charIDToTypeID( "Fl  " );

        var idWht = charIDToTypeID( "Wht " );

        desc6.putEnumerated( idFl, idFl, idWht );

        var idDpth = charIDToTypeID( "Dpth" );

        desc6.putInteger( idDpth, 8 );

        var idprofile = stringIDToTypeID( "profile" );

        desc6.putString( idprofile, """sRGB IEC61966-2.1""" );

        var idGdes = charIDToTypeID( "Gdes" );

            var list1 = new ActionList();

        desc6.putList( idGdes, list1 );

    var idDcmn = charIDToTypeID( "Dcmn" );

    desc5.putObject( idNw, idDcmn, desc6 );

    var idDocI = charIDToTypeID( "DocI" );

    desc5.putInteger( idDocI, 563 );

executeAction( idMk, desc5, DialogModes.NO );

// =======================================================

var idMk = charIDToTypeID( "Mk  " );

    var desc7 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref1 = new ActionReference();

        var idcontentLayer = stringIDToTypeID( "contentLayer" );

        ref1.putClass( idcontentLayer );

    desc7.putReference( idnull, ref1 );

    var idUsng = charIDToTypeID( "Usng" );

        var desc8 = new ActionDescriptor();

        var idType = charIDToTypeID( "Type" );

            var desc9 = new ActionDescriptor();

            var idClr = charIDToTypeID( "Clr " );

                var desc10 = new ActionDescriptor();

                var idRd = charIDToTypeID( "Rd  " );

                desc10.putDouble( idRd, 255.000000 );

                var idGrn = charIDToTypeID( "Grn " );

                desc10.putDouble( idGrn, 0.000000 );

                var idBl = charIDToTypeID( "Bl  " );

                desc10.putDouble( idBl, 0.000000 );

            var idRGBC = charIDToTypeID( "RGBC" );

            desc9.putObject( idClr, idRGBC, desc10 );

        var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

        desc8.putObject( idType, idsolidColorLayer, desc9 );

        var idShp = charIDToTypeID( "Shp " );

            var desc11 = new ActionDescriptor();

            var idunitValueQuadVersion = stringIDToTypeID( "unitValueQuadVersion" );

            desc11.putInteger( idunitValueQuadVersion, 1 );

            var idTop = charIDToTypeID( "Top " );

            var idPxl = charIDToTypeID( "#Pxl" );

            desc11.putUnitDouble( idTop, idPxl, 161.000000 );

            var idLeft = charIDToTypeID( "Left" );

            var idPxl = charIDToTypeID( "#Pxl" );

            desc11.putUnitDouble( idLeft, idPxl, 202.000000 );

            var idBtom = charIDToTypeID( "Btom" );

            var idPxl = charIDToTypeID( "#Pxl" );

            desc11.putUnitDouble( idBtom, idPxl, 358.000000 );

            var idRght = charIDToTypeID( "Rght" );

            var idPxl = charIDToTypeID( "#Pxl" );

            desc11.putUnitDouble( idRght, idPxl, 457.000000 );

        var idElps = charIDToTypeID( "Elps" );

        desc8.putObject( idShp, idElps, desc11 );

        var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

            var desc12 = new ActionDescriptor();

            var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );

            desc12.putInteger( idstrokeStyleVersion, 2 );

            var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );

            desc12.putBoolean( idstrokeEnabled, false );

            var idfillEnabled = stringIDToTypeID( "fillEnabled" );

            desc12.putBoolean( idfillEnabled, true );

            var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );

            var idPxl = charIDToTypeID( "#Pxl" );

            desc12.putUnitDouble( idstrokeStyleLineWidth, idPxl, 1.000000 );

            var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );

            var idPnt = charIDToTypeID( "#Pnt" );

            desc12.putUnitDouble( idstrokeStyleLineDashOffset, idPnt, 0.000000 );

            var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );

            desc12.putDouble( idstrokeStyleMiterLimit, 100.000000 );

            var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

            var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );

            var idstrokeStyleButtCap = stringIDToTypeID( "strokeStyleButtCap" );

            desc12.putEnumerated( idstrokeStyleLineCapType, idstrokeStyleLineCapType, idstrokeStyleButtCap );

            var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

            var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );

            var idstrokeStyleMiterJoin = stringIDToTypeID( "strokeStyleMiterJoin" );

            desc12.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, idstrokeStyleMiterJoin );

            var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

            var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );

            var idstrokeStyleAlignInside = stringIDToTypeID( "strokeStyleAlignInside" );

            desc12.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignInside );

            var idstrokeStyleScaleLock = stringIDToTypeID( "strokeStyleScaleLock" );

            desc12.putBoolean( idstrokeStyleScaleLock, false );

            var idstrokeStyleStrokeAdjust = stringIDToTypeID( "strokeStyleStrokeAdjust" );

            desc12.putBoolean( idstrokeStyleStrokeAdjust, false );

            var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );

                var list2 = new ActionList();

            desc12.putList( idstrokeStyleLineDashSet, list2 );

            var idstrokeStyleBlendMode = stringIDToTypeID( "strokeStyleBlendMode" );

            var idBlnM = charIDToTypeID( "BlnM" );

            var idNrml = charIDToTypeID( "Nrml" );

            desc12.putEnumerated( idstrokeStyleBlendMode, idBlnM, idNrml );

            var idstrokeStyleOpacity = stringIDToTypeID( "strokeStyleOpacity" );

            var idPrc = charIDToTypeID( "#Prc" );

            desc12.putUnitDouble( idstrokeStyleOpacity, idPrc, 100.000000 );

            var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );

                var desc13 = new ActionDescriptor();

                var idClr = charIDToTypeID( "Clr " );

                    var desc14 = new ActionDescriptor();

                    var idRd = charIDToTypeID( "Rd  " );

                    desc14.putDouble( idRd, 0.000000 );

                    var idGrn = charIDToTypeID( "Grn " );

                    desc14.putDouble( idGrn, 0.000000 );

                    var idBl = charIDToTypeID( "Bl  " );

                    desc14.putDouble( idBl, 0.000000 );

                var idRGBC = charIDToTypeID( "RGBC" );

                desc13.putObject( idClr, idRGBC, desc14 );

            var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );

            desc12.putObject( idstrokeStyleContent, idsolidColorLayer, desc13 );

            var idstrokeStyleResolution = stringIDToTypeID( "strokeStyleResolution" );

            desc12.putDouble( idstrokeStyleResolution, 100.000000 );

        var idstrokeStyle = stringIDToTypeID( "strokeStyle" );

        desc8.putObject( idstrokeStyle, idstrokeStyle, desc12 );

    var idcontentLayer = stringIDToTypeID( "contentLayer" );

    desc7.putObject( idUsng, idcontentLayer, desc8 );

    var idLyrI = charIDToTypeID( "LyrI" );

    desc7.putInteger( idLyrI, 2 );

executeAction( idMk, desc7, DialogModes.NO );

// =======================================================

var idASty = charIDToTypeID( "ASty" );

    var desc15 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref2 = new ActionReference();

        var idStyl = charIDToTypeID( "Styl" );

        ref2.putName( idStyl, "Shiny Metal" );

    desc15.putReference( idnull, ref2 );

    var idT = charIDToTypeID( "T   " );

        var ref3 = new ActionReference();

        var idLyr = charIDToTypeID( "Lyr " );

        var idOrdn = charIDToTypeID( "Ordn" );

        var idTrgt = charIDToTypeID( "Trgt" );

        ref3.putEnumerated( idLyr, idOrdn, idTrgt );

    desc15.putReference( idT, ref3 );

    var idGrup = charIDToTypeID( "Grup" );

    desc15.putBoolean( idGrup, true );

executeAction( idASty, desc15, DialogModes.NO );

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 07, 2017 Sep 07, 2017

Copy link to clipboard

Copied

And here is the new Action manager code that get recorded when the cc 2017 New document interface is  use,  Clean SL will bypass it and start with the make document if you do not load the full log file.

Capture.jpg

 

// =======================================================

var idinvokeCommand = stringIDToTypeID( "invokeCommand" );

    var desc26 = new ActionDescriptor();

    var idcommandID = stringIDToTypeID( "commandID" );

    desc26.putInteger( idcommandID, 10 );

    var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );

    desc26.putBoolean( idkcanDispatchWhileModal, true );

executeAction( idinvokeCommand, desc26, DialogModes.NO );

// =======================================================

var idmodalHTMLPending = stringIDToTypeID( "modalHTMLPending" );

    var desc27 = new ActionDescriptor();

    var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );

    desc27.putBoolean( idkcanDispatchWhileModal, true );

    var idisPending = stringIDToTypeID( "isPending" );

    desc27.putBoolean( idisPending, true );

    var idExtn = charIDToTypeID( "Extn" );

    desc27.putString( idExtn, """com.adobe.ccx.fnft""" );

executeAction( idmodalHTMLPending, desc27, DialogModes.NO );

// =======================================================

var idconvertJSONdescriptor = stringIDToTypeID( "convertJSONdescriptor" );

    var desc28 = new ActionDescriptor();

    var idjson = stringIDToTypeID( "json" );

    desc28.putString( idjson, """{"_obj":"object","pixelScaleFactorList":[{"custom":false,"name":"Square Pixels","value":1},{"custom":false,"name":"D1/DV NTSC","value":0.9091},{"custom":false,"name":"D1/DV PAL","value":1.094},{"custom":false,"name":"D1/DV NTSC Widescreen","value":1.2121},{"custom":false,"name":"HDV 1080/DVCPRO HD 720","value":1.333},{"custom":false,"name":"D1/DV PAL Widescreen","value":1.4587},{"custom":false,"name":"Anamorphic 2:1","value":2},{"custom":false,"name":"DVCPRO HD 1080","value":1.5}]}""" );

executeAction( idconvertJSONdescriptor, desc28, DialogModes.NO );

// =======================================================

var idmodalHTMLPending = stringIDToTypeID( "modalHTMLPending" );

    var desc29 = new ActionDescriptor();

    var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );

    desc29.putBoolean( idkcanDispatchWhileModal, true );

    var idisPending = stringIDToTypeID( "isPending" );

    desc29.putBoolean( idisPending, false );

    var idExtn = charIDToTypeID( "Extn" );

    desc29.putString( idExtn, """com.adobe.ccx.fnft""" );

executeAction( idmodalHTMLPending, desc29, DialogModes.NO );

// =======================================================

var idMk = charIDToTypeID( "Mk  " );

    var desc30 = new ActionDescriptor();

    var idNw = charIDToTypeID( "Nw  " );

        var desc31 = new ActionDescriptor();

        var idartboard = stringIDToTypeID( "artboard" );

        desc31.putBoolean( idartboard, false );

        var idMd = charIDToTypeID( "Md  " );

        var idRGBM = charIDToTypeID( "RGBM" );

        desc31.putClass( idMd, idRGBM );

        var idWdth = charIDToTypeID( "Wdth" );

        var idRlt = charIDToTypeID( "#Rlt" );

        desc31.putUnitDouble( idWdth, idRlt, 504.000000 );

        var idHght = charIDToTypeID( "Hght" );

        var idRlt = charIDToTypeID( "#Rlt" );

        desc31.putUnitDouble( idHght, idRlt, 360.000000 );

        var idRslt = charIDToTypeID( "Rslt" );

        var idRsl = charIDToTypeID( "#Rsl" );

        desc31.putUnitDouble( idRslt, idRsl, 100.000000 );

        var idpixelScaleFactor = stringIDToTypeID( "pixelScaleFactor" );

        desc31.putDouble( idpixelScaleFactor, 1.000000 );

        var idFl = charIDToTypeID( "Fl  " );

        var idFl = charIDToTypeID( "Fl  " );

        var idWht = charIDToTypeID( "Wht " );

        desc31.putEnumerated( idFl, idFl, idWht );

        var idDpth = charIDToTypeID( "Dpth" );

        desc31.putInteger( idDpth, 8 );

        var idprofile = stringIDToTypeID( "profile" );

        desc31.putString( idprofile, """sRGB IEC61966-2.1""" );

        var idGdes = charIDToTypeID( "Gdes" );

            var list3 = new ActionList();

        desc31.putList( idGdes, list3 );

    var idDcmn = charIDToTypeID( "Dcmn" );

    desc30.putObject( idNw, idDcmn, desc31 );

    var idDocI = charIDToTypeID( "DocI" );

    desc30.putInteger( idDocI, 582 );

executeAction( idMk, desc30, DialogModes.NO );

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 08, 2017 Sep 08, 2017

Copy link to clipboard

Copied

Updated Clean SL to version 1.1, that increments function names when processing multiple logs.

JJMack This update fixes your first issue. The problem originally was that Clean SL wasn't tracking function names, and in your example function make() was declared twise, and that broke the output code. Updated version checks for duplicate function names and increments them if necessary.

However, I wasn't able to fix your second issue. Actually, I wasn't even able to evaluate your ActionManager code. So if AM code does not work, Clean SL code will also not work ¯\_(ツ)_/¯

smithcgl9043167 - way to go! I am glad you find Clean SL usefull.

xbytor2 - Thank you for the tip. I didn't know that. I dont have much experience with ActionManager. However, could you elaborate more about that? Maybe I could build some look-up list for charID and skip converting them if they match to some conflicting properties? Or maybe Clean SL should investigate that part of the code and decide if it's a Saturation or Start? Could you give me more pointers on this?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 08, 2017 Sep 08, 2017

Copy link to clipboard

Copied

Yes I find newer version of Phostoshop that the scriptlistener seems to record Junk action manager code the does not seem to work only generates errors whent you try use it.  Creating the same stepts in CS6 the junk does not get recorded.  I think what the junk is because of sone of the names in it has to do the html panel used in new ddocument new UI interface.  I'll switch to classic anf see what script listener generates.  I have not tried the code with X's script code. I do not see the point for the code does not work with Photoshop.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 08, 2017 Sep 08, 2017

Copy link to clipboard

Copied

CC 2017 still records other junk not the same junk be fone the Mak new document when theold net documet interface is used. These three steps???

 

// =======================================================

var idinvokeCommand = stringIDToTypeID( "invokeCommand" );

    var desc4 = new ActionDescriptor();

    var idcommandID = stringIDToTypeID( "commandID" );

    desc4.putInteger( idcommandID, 10 );

    var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );

    desc4.putBoolean( idkcanDispatchWhileModal, true );

executeAction( idinvokeCommand, desc4, DialogModes.NO );

// =======================================================

var idmodalStateChanged = stringIDToTypeID( "modalStateChanged" );

    var desc5 = new ActionDescriptor();

    var idLvl = charIDToTypeID( "Lvl " );

    desc5.putInteger( idLvl, 1 );

    var idStte = charIDToTypeID( "Stte" );

    var idStte = charIDToTypeID( "Stte" );

    var identer = stringIDToTypeID( "enter" );

    desc5.putEnumerated( idStte, idStte, identer );

    var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );

    desc5.putBoolean( idkcanDispatchWhileModal, true );

executeAction( idmodalStateChanged, desc5, DialogModes.NO );

// =======================================================

var idmodalStateChanged = stringIDToTypeID( "modalStateChanged" );

    var desc6 = new ActionDescriptor();

    var idLvl = charIDToTypeID( "Lvl " );

    desc6.putInteger( idLvl, 0 );

    var idStte = charIDToTypeID( "Stte" );

    var idStte = charIDToTypeID( "Stte" );

    var idexit = stringIDToTypeID( "exit" );

    desc6.putEnumerated( idStte, idStte, idexit );

    var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );

    desc6.putBoolean( idkcanDispatchWhileModal, true );

executeAction( idmodalStateChanged, desc6, DialogModes.NO );

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 08, 2017 Sep 08, 2017

Copy link to clipboard

Copied

Sorry I don't understand.

What are you trying to achieve?

I copy/pasted your provided AM code to ESTK and it crashes on line executeAction( idinvokeCommand, desc4, DialogModes.NO );

Clean SL does not modify your AM code, it simply cleans it up by moving strings around - if ESTK is not able to evaluate AM code, nor it will be able to evaluate Clean SL code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 08, 2017 Sep 08, 2017

Copy link to clipboard

Copied

Capture.jpg

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 08, 2017 Sep 08, 2017

Copy link to clipboard

Copied

Seems as if it worked. Perfect!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 08, 2017 Sep 08, 2017

Copy link to clipboard

Copied

Yes using my bat file is a small window's window allows be to  manage and edit the scriptlistener log file. Your Clean SL script can evaluate the action manager code in the log as long as I clean out the junk steps in the log file.  And if that works your script can cleans the code and evaluate the cleaned code.  And save a text file with that code so can use the functions in my Photoshop scripting.  Look like Clean SL will be of  great value for me.

Thank You.

Here is the Bat file I use an what  its window looks like one my machine.

Capture.jpg

Capture.jpg

@Echo Off

:loop

CLS

rem Display Log File Size

Dir "%USERPROFILE%\Desktop\ScriptingListenerJS.log" /T:W /4 | find "%ScriptingListenerJS.log"

rem Display Log Attributes  R read only Locked no R log is Unlocked

Attrib "%USERPROFILE%\Desktop\ScriptingListenerJS.log"

Rem If timeout is use the above display lines will refresh over time else you need to use enter or number

CHOICE /C 123456 /N /T 300 /D 6 /M "Enter:1 to Lock, 2 to Unlock, 3 to Edit, 4 to Clear, 5 To Exit :"

Echo %ERRORLEVEL%

if %ERRORLEVEL%==6 goto timeout

if %ERRORLEVEL%==1 goto one

if %ERRORLEVEL%==2 goto two

if %ERRORLEVEL%==3 goto three

if %ERRORLEVEL%==4 goto four

if %ERRORLEVEL%==5 goto five

goto loop

:timeout

goto loop

:one

Attrib +R "%USERPROFILE%\Desktop\ScriptingListenerJS.log"

goto loop

:two

Attrib -R "%USERPROFILE%\Desktop\ScriptingListenerJS.log"

goto loop

:three

        Rem inline command use CMD independate command use start

CMD /C notepad "%USERPROFILE%\Desktop\ScriptingListenerJS.log"

rem Start notepad "%USERPROFILE%\Desktop\ScriptingListenerJS.log"

goto loop

:four

        Rem If the script log file is unlocked not read only  this echo will clear it

Echo. > "%USERPROFILE%\Desktop\ScriptingListenerJS.log"

goto loop

:five

EXIT

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 08, 2017 Sep 08, 2017

Copy link to clipboard

Copied

That sounds as a perfect idea!

Lets take our conversation privately, so we can work this out and I'll publish an update once it's ready.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 08, 2017 Sep 08, 2017

Copy link to clipboard

Copied

You new code worked better. When I evaluated the cleaned code it created a new document but the document was not fully rendered till I closed Clean SL and Photoshop refreshed the documents displayed. When Clean SL interface was up the new document created was only refreshed to the point where the oval path was visible.  The shape fill and layer style were not rendered.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 08, 2017 Sep 08, 2017

Copy link to clipboard

Copied

Yeap, I am aware of Photoshop not updating when modal window is opened. This is just something we have to cope with.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 08, 2017 Sep 08, 2017

Copy link to clipboard

Copied

Tomas, what xbytor has mentioned is true – but I think you shouldn't worry too much about it.

Fact is that most of the times you have charIDs that map into more readable stringIDs, but sometimes two different stringIDs map to the same charID. For instance:

charIDToTypeID( "Grn " ) == stringIDToTypeID( "grain" ) == stringIDToTypeID( "green" )

the resulting typeID is the very same. The "Get Equivalent ID Code" by Mikaeru provides both of them (you may want to look at it to see how he's doing it), but picking the right one based on the context seems to me an awful amount of work.

Davide

Davide Barranca - PS developer and author
www.ps-scripting.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 08, 2017 Sep 08, 2017

Copy link to clipboard

Copied

Thanks Davide_Barranca​. I am not stressing about it at all. There's an option in UI to turn off charID to string ID. So it something brakes, user can always skip that step. So all is good.

However, I don't think it's too much of work when you know how AM work and have ninja-guru-RegExp certificate (I don't actually have one)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Sep 07, 2017 Sep 07, 2017

Copy link to clipboard

Copied

One thing you have to be aware of is that string ids and char ids are not a one-to-one mapping.

For instance, "Strt" maps to "Saturation" and "Start".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 08, 2017 Sep 08, 2017

Copy link to clipboard

Copied

Right now I'm looking to see if there is a newer version of scriptlistener for CC 2017.  I do not normally use CC 2017.  I use CC 2014.   Your Clean SL works better in CS6 and CC 2014.  For the Scriptlistener does not record the  junk it records in CC 2017.  I have not tested CC 2015 and CC 2015.5. I do not use them. I do have them installed.

The onle plugin I see on Adobe site is dated 2012

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 08, 2017 Sep 08, 2017

Copy link to clipboard

Copied

Tomas a cpiple of questions.

First when I open your Clean SL script there is some code in the left side panel.  What is that code where does it come from its not in my scriptlistemer log file.  I do not even use artboards but the code I see seems to be for creating an artboard.

Capture.jpg

Second the left side panel source code is editable and that is a grate feature.  However the next panel the clean code is not editable. It the any chance the you could make that panel editable like the source panel.  I would like to try to add parameters to your functions set their values  and add them into the function you made and then be able to have Clean SL evaluate the changed code.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 08, 2017 Sep 08, 2017

Copy link to clipboard

Copied

JJMack​ The starting code you see once you launch Clean SL is just a demo code. Clean SL doesn't read ScriptingListener.log file upon loading. I decided to leave that test code in there so users don't get empty screen when launching Clean SL. So feel free to ignore and delete it.

I might implement options in the future to "remember source code / clean code after panel closes", so it would load last code you had in those edittext boxes.

Regarding not being able to edit clean code's edittext - well, you should be able to edit both of them. Unless there's some bug on Windows that prevents from entering text manually.

I tested on Mac CS6, CC2014 & CC2017 and I am able to edit those textboxes manually.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 09, 2017 Sep 09, 2017

Copy link to clipboard

Copied

That's a great job

thanks for sharing

I suggest inserting this output change

if (pathToFile) {

saveFile (pathToFile, "jsx", etOutputText.text);

win.close ();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 09, 2017 Sep 09, 2017

Copy link to clipboard

Copied

Hi Tomas,

this is 100% personal taste, and by the way it's easy to fix later: I prefer shorter names for descriptors: e.g. I used "desc", "desc2", "desc3", "list", "list2", "list3", "ref", "ref2", you get the idea 🙂 and now I've shrunk them even more like "d", "l", "r", etc.

When it's winter, and you're really really bored, you might add this as a preference 🙂 Also, last SL item automatically loaded would be a nice thing (or with a preference setting the number of logged functions to retrieve). I'm just throwing on the table a couple of ideas that came to my mind, your tool is already a great help as is – and thank you for sharing it!

Best

Davide

Davide Barranca - PS developer and author
www.ps-scripting.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2017 Sep 09, 2017

Copy link to clipboard

Copied

Tomas

The Last SL item idea Davide suggests Is what I thought your Demo Code was but I then saw it was not. That is why I asked where that Artboard step came from.  I thought the last SL step would be a good startup default.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines