• 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

15.3K

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
LEGEND ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

Desktop file is only a bonus stuff

(remainder from very first version I kept).

Converted code is stored in Windows clipboard.

So after you ran script and then use ctrl v in any editor the output will be pasted.

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 ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

Yes. I did it for myself and shared with others. I don't need more code of script listener at one time.

It could be interesting for me to do all the ScriptingListenerJS at once

can you modify your script to do this?

Kukurykus  ha scritto

Desktop file is only a bonus stuff

(remainder from very first version I kept).

Converted code is stored in Windows clipboard.

So after you ran script and then use ctrl v in any editor the output will be pasted.

I tried but on mac it does not work

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
LEGEND ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

In December 2016 I created topic on this forum where some users joined discussion. I was happy to use their ideas to introduce into my script, although my personal goal was already achieved. Unfortunately there were only two serious requests what to change. I did that as wanted it was useful not only for me but also for others. Noone else suggested me anything more so I assumed script is perfect. If people had some wishes in that time I surely would implement them. As far as they didn't have it seemed everyone who uses it is fine with results it gives. Although on the other forum you got link to I see there are over 150 downloads (excluding probably many not recorded copying actions) of this script there was not even one person from over a year who'd have asked to add something or modify in. Well why I had to do something more then if for me that was fine while looking at (no) reactions of others they were okey with too 🙂

 

You may post your ideas in Action Manager (Script Listener) code converter script! as here I mainly came to leave my feedback for Tomas Sinkunas script. Then it turned into unexpected direction. So if you have some ideas post them there. There was time for it a year ago of course, while at the moment I'm not interested to develop this script more. Still say what you'd like to have and when one day I'm maybe back to elaborate on this script I see what I can do 😉

 

In the last line of script I used code of Macintosh user  JavierAroche , so if that worked for him then should for you too. I can test it only on Windows, but you may read topic where everything started and try his samples he shared with me. Try them in the most basic form, so without my script, just to see first that sole pbcopy command works for you on Macintosh. Then we can talk 😉


Regarding reading whole SL, that's not hard after all, but I'd like to make time for all changes at once instead of adding new properties once for a while.

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 ,
Mar 21, 2018 Mar 21, 2018

Copy link to clipboard

Copied

Kukurykus

You are definitely right

the topic was used incorrectly

however, if you look back at the script tomorrow and enter the function

that will convert everything the script would be great.

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 ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

That is also what seem to be in the Clipboard. The first read seem to reads the last  step on the scriptlistener log is that all you script does?  which is this:

var idsetd = charIDToTypeID( "setd" );

    var desc116 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var ref15 = new ActionReference();

        var idChnl = charIDToTypeID( "Chnl" );

        var idfsel = charIDToTypeID( "fsel" );

        ref15.putProperty( idChnl, idfsel );

    desc116.putReference( idnull, ref15 );

    var idT = charIDToTypeID( "T   " );

    var idOrdn = charIDToTypeID( "Ordn" );

    var idNone = charIDToTypeID( "None" );

    desc116.putEnumerated( idT, idOrdn, idNone );

executeAction( idsetd, desc116, DialogModes.NO );

I just ran the script and will now will use Ctrl+v Here

function cTT(v) {return charIDToTypeID(v)}; function sTT(v) {return stringIDToTypeID(v)}

function someName() {

(ref1 = new ActionReference()).putProperty(sTT('channel'), sTT('selection'));

(dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref1)

dsc1.putEnumerated(sTT('to'), sTT('ordinal'), sTT('none'))

executeAction(sTT('set'), dsc1, DialogModes.NO);

}

someName()

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
LEGEND ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

That is it. What else should be in output of such convertion to be more friendly for user (however everyone has own taste)? You may use it for huge code to see more differences, maybe you even find some bug. It never failed yet, but who knows

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 ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

Thank you as Alway.  I thought that was it.  I have problems reading your scripts because of my  limited  knowledge of javascript.

I use  Thomas script and find with each  release of Photoshop the scriptlistener seems to through out more  and more junk that is not useable and gets in the way.  Thomas added code in his script for me so I can weed out that  code which makes using cleaned up scriptlistener code easier for me the hacker to use.

It good to have you here too.

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
LEGEND ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

Thank you and read this post: PS Scripting - check if layer link is temporary disabled (of Jarda Bereza​). It seems they're not completely garbage as r-bin used 'command' in this code: PS Scripting - check if layer link is temporary disabled

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
Enthusiast ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

Script listener is listening events. And some events has only informative character. You can listen them in other places not only in .log file. But also in plugins or via notifiers. And because in CC2018 is new learn panel which uses these listening, they added new informations(garbage) for read only purposes.

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 ,
Mar 21, 2018 Mar 21, 2018

Copy link to clipboard

Copied

 

Jarda Bereza wrote

CC2018 is new learn panel which uses these listening, they added new informations(garbage) for read only purposes.

I find I too need to add garbage to information matadata the get around garbage Adobe added in Photoshop Scripting in CC 2015.5. sometime garbage is needed.

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
LEGEND ,
Mar 20, 2018 Mar 20, 2018

Copy link to clipboard

Copied

Yes. I did it for myself and shared with others. I don't need more code of script listener at one time. The way I use it is to focus only on one/last code I want to implement to some srcipt I'm writing. As I do it once a while earlier records are not important to me. Outputs may be taken as final result and in their current shape are equivalnt to those other scripts like this one does or be manually modified what I do additionally. That second part is no needed, but currently there isn't any program that would can do it.

For example, filling with white colour:

var idFl = charIDToTypeID( "Fl  " );

    var desc729 = new ActionDescriptor();

    var idUsng = charIDToTypeID( "Usng" );

    var idFlCn = charIDToTypeID( "FlCn" );

    var idWht = charIDToTypeID( "Wht " );

    desc729.putEnumerated( idUsng, idFlCn, idWht );

    var idOpct = charIDToTypeID( "Opct" );

    var idPrc = charIDToTypeID( "#Prc" );

    desc729.putUnitDouble( idOpct, idPrc, 100.000000 );

    var idMd = charIDToTypeID( "Md  " );

    var idBlnM = charIDToTypeID( "BlnM" );

    var idNrml = charIDToTypeID( "Nrml" );

    desc729.putEnumerated( idMd, idBlnM, idNrml );

executeAction( idFl, desc729, DialogModes.NO );

Converted:

function cTT(v) {return charIDToTypeID(v)}; function sTT(v) {return stringIDToTypeID(v)}

function someName() {

     (dsc1 = new ActionDescriptor()).putEnumerated(sTT('using'), sTT('fillContents'), sTT('white'))

     dsc1.putUnitDouble(sTT('opacity'), sTT('percentUnit'), 100)

     dsc1.putEnumerated(sTT('mode'), sTT('blendMode'), sTT('normal'))

     executeAction(sTT('fill'), dsc1, DialogModes.NO);

}

someName()

Modified (all possible convertion outputs into one function):

function sTT(v) {return stringIDToTypeID(v)}

function fil(v1, v2, v3, v4, v5, v6, v7) {// FILLING:

     (dsc1 = new ActionDescriptor()).putEnumerated(sTT('using'), sTT('fillContents'), sTT(v1))

     function c() {

          (dsc2 = new ActionDescriptor()).putUnitDouble(sTT('hue'), sTT('angleUnit'), v5)

          for(i = 0; i < (arr = ['saturation', 'brightness']).length; i++) dsc2.putDouble(sTT(arr), eval('v' + (i + 6)))

          dsc1.putObject(sTT(v1), sTT('HSBColorClass'), dsc2)

     }

     function p() {

          eval("(dsc2 = new ActionDescriptor())" + (v5 ? ".putString(sTT('name'), v5)" : ""))

          if (v6) dsc2.putString(sTT('ID'), v6); dsc1.putObject(sTT(v1), sTT(v1), dsc2)

          if (v7) dsc1.putPath(sTT('decoScriptFile'), new File(v7))

     }

     obj = {color: c, pattern: p}, (obj[v1] || function(){})()

     dsc1.putUnitDouble(sTT('opacity'), sTT('percentUnit'), v2 || 100)

     dsc1.putEnumerated(sTT('mode'), sTT('blendMode'), sTT(v3 || 'normal'))

     dsc1.putBoolean(sTT('preserveTransparency'), v4 || false)

     executeAction(sTT('fill'), dsc1, DialogModes.NO)

     // v1: 'foregroundColor', 'backgroundColor', 'color', 'contentAware', 'pattern', 'saved', 'black', 'gray', 'white'; v2: (1 - 100)

     // v3: 'normal', 'dissolve', 'behind', 'clearEnum', 'darken', 'multiply', 'colorBurn', 'linearBurn', 'darkerColor', 'lighten',

     // 'screen', 'colorDodge', 'linearDodge', 'lighterColor', 'overlay', 'softLight', 'hardLight', 'vividLight', 'linearLight'

     // 'pinLight', 'hardMix', 'difference', 'exclusion', 'blendSubtraction', 'blendDivide', 'hue', 'saturation', 'color', 'luminosity'

     // v4: boolean; v5: (0 - 360) / string; v6: (0 - 100) / string; v7: (0 - 100) / string

}

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
People's Champ ,
Mar 21, 2018 Mar 21, 2018

Copy link to clipboard

Copied

A simple event_listener script. Version 0.0.

Assign a notifier to the "Everything" event for this script.

In the file "~ / EventListener.log" you get the analog of ScriptingListenerJS.log.

The plugin ScriptListener.8li is not needed.

Works with Puppet Warp

var dsc_name = "d";

var lst_name = "l";

var ref_name = "r";

var dsc_numb = 0;

var lst_numb = -1;

var ref_numb = -1;

var file = new File("~/EventListener.log");

file.open("a");

file.writeln("\n");

var rem = " ///////////////////////////////////////////////////";

if (typeIDToStringID(arguments[1]))    file.writeln("// Event: " + typeIDToStringID(arguments[1]) + rem);

else if (typeIDToCharID(arguments[1])) file.writeln("// Event: " + typeIDToCharID(arguments[1]) + rem);

else                                   file.writeln("// UNKNOWN EVENT !!!" + rem);

file.writeln("");

file.writeln(parse_desc(arguments[0]));

file.writeln("executeAction(" + k2s(arguments[1]) + ", d, DialogModes.NO);"); 

file.close();

//////////////////////////////////////////////////////////////////////////

function next_dsc() { return dsc_numb++; }

function next_lst() { return lst_numb++; }

function next_ref() { return ref_numb++; }

//////////////////////////////////////////////////////////////////////////

function k2s(key)

    {

    try

        {

        var str = typeIDToStringID(key);

        var chr = typeIDToCharID(key);

        if (str) return "stringIDToTypeID(\"" + str + "\")";

        else if (chr) return "charIDToTypeID(\"" + chr + "\")";

        else return "Bug!";

        }

    catch (e) { throw(e); }

    }

////////////////////////////////////////////////////////////////////////////////////////////

function dat(s)

    {

    try

        {

        var ret = "String.fromCharCode(";

        for (var i = 0; i < s.length; i++)

            {

            var h = s.charCodeAt(i).toString(16).toUpperCase();

            if (h.length == 1) h = "0" + h;

            ret += "0x" + h;

            if (i != s.length-1) ret += ",";

            }

        ret += ")";

       

        return ret;

        }

    catch (e) { throw(e); }

    }

//////////////////////////////////////////////////////////////////////////

function parse_desc(desc)

    {

    try

        {

        var name = dsc_name + (dsc_numb?dsc_numb:"");

        var code = "var " + name + " = new ActionDescriptor();";

        for (var i = 0; i < desc.count; i++)

            {

            var key  = desc.getKey(i);

            var type = desc.getType(key);

            var str = "// UNNKOWN TYPE!";

            var var_numb;

            switch (type)

                {

                case DescValueType.OBJECTTYPE:    ++dsc_numb; var_numb = dsc_numb; str = parse_desc(desc.getObjectValue(key)) + "\n" + name + ".putObject(" + k2s(key)    + ", " + k2s(desc.getObjectType(key)) + ", " + dsc_name + (var_numb?var_numb:"") + ");"; break;

                case DescValueType.LISTTYPE:      ++lst_numb; var_numb = lst_numb; str = parse_list(desc.getList(key))        + "\n" + name + ".putList("   + k2s(key)    + ", " + lst_name + (var_numb?var_numb:"") + ");"; break;

                case DescValueType.REFERENCETYPE: ++ref_numb; var_numb = ref_numb; str = parse_ref(desc.getReference(key))    + "\n" + name + ".putReference(" + k2s(key) + ", " + ref_name + (var_numb?var_numb:"") + ");"; break;

                case DescValueType.CLASSTYPE:        str = name + ".putClass(" + k2s(key) + ", " + k2s(desc.getClass(key))   + ");"; break;

                case DescValueType.RAWTYPE:          str = name + ".putData("  + k2s(key) + ", " + dat(desc.getData(key))    + ");"; break;;

                case DescValueType.BOOLEANTYPE:      str = name + ".putBoolean("      + k2s(key) + ", " + desc.getBoolean(key)      + ");"; break;

                case DescValueType.INTEGERTYPE:      str = name + ".putInteger("      + k2s(key) + ", " + desc.getInteger(key)      + ");"; break;

                case DescValueType.DOUBLETYPE:       str = name + ".putDouble("       + k2s(key) + ", " + desc.getDouble(key)       + ");"; break;

                case DescValueType.LARGEINTEGERTYPE: str = name + ".putLargeInteger(" + k2s(key) + ", " + desc.getLargeInteger(key) + ");"; break;

                case DescValueType.STRINGTYPE:       str = name + ".putString(" + k2s(key) +          ", \"" + desc.getString(key) + "\");";  break;

                case DescValueType.ALIASTYPE:        str = name + ".putPath("   + k2s(key) + ", new File(\"" + desc.getPath(key)   + "\"));"; break;

                case DescValueType.UNITDOUBLE:       str = name + ".putUnitDouble(" + k2s(key) + ", " + k2s(desc.getUnitDoubleType(key))  + ", " + desc.getUnitDoubleValue(key)       + ");"; break;

                case DescValueType.ENUMERATEDTYPE:   str = name + ".putEnumerated(" + k2s(key) + ", " + k2s(desc.getEnumerationType(key)) + ", " + k2s(desc.getEnumerationValue(key)) + ");"; break;

                }

            code += "\n" + str;

            }

        return code;

        }

    catch (e) { _alert(e); throw(e); }

    }

//////////////////////////////////////////////////////////////////////////

function parse_list(list)

    {

    try

        {

        var name = lst_name + (lst_numb?lst_numb:"");

        var code = "var " + name + " = new ActionList();";

        for (var i = 0; i < list.count; i++)

            {

            var type = list.getType(i);

            var str = "// UNNKOWN TYPE!";

            var var_numb;

            switch (type)

                {

                case DescValueType.OBJECTTYPE:    ++dsc_numb; var_numb = dsc_numb; str = parse_desc(list.getObjectValue(i)) + "\n" + name + ".putObject("    + k2s(list.getObjectType(i)) + ", " + dsc_name + (var_numb?var_numb:"") + ");"; break;

                case DescValueType.LISTTYPE:      ++lst_numb; var_numb = lst_numb; str = parse_list(list.getList(i))        + "\n" + name + ".putList("      + lst_name + (var_numb?var_numb:"") + ");"; break;

                case DescValueType.REFERENCETYPE: ++ref_numb; var_numb = ref_numb; str = parse_ref(list.getReference(i))    + "\n" + name + ".putReference(" + ref_name + (var_numb?var_numb:"") + ");"; break;

                case DescValueType.CLASSTYPE:        str = name + ".putClass(" + k2s(list.getClass(i)) + ");"; break;

                case DescValueType.RAWTYPE:          str = name + ".putData("  + dat(desc.getData(i))  + ");"; break;;

                case DescValueType.BOOLEANTYPE:      str = name + ".putBoolean("      + list.getBoolean(i)      + ");"; break;

                case DescValueType.INTEGERTYPE:      str = name + ".putInteger("      + list.getInteger(i)      + ");"; break;

                case DescValueType.DOUBLETYPE:       str = name + ".putDouble("       + list.getDouble(i)       + ");"; break;

                case DescValueType.LARGEINTEGERTYPE: str = name + ".putLargeInteger(" + list.getLargeInteger(i) + ");"; break;

                case DescValueType.STRINGTYPE:       str = name + ".putString(" +          "\"" + list.getString(i) + "\");";  break;

                case DescValueType.ALIASTYPE:        str = name + ".putPath("   + "new File(\"" + list.getPath(i)   + "\"));"; break;

                case DescValueType.UNITDOUBLE:       str = name + ".putUnitDouble(" + k2s(list.getUnitDoubleType(i))  + ", " + list.getUnitDoubleValue(i)       + ");"; break;

                case DescValueType.ENUMERATEDTYPE:   str = name + ".putEnumerated(" + k2s(list.getEnumerationType(i)) + ", " + k2s(list.getEnumerationValue(i)) + ");"; break;

                }

            code += "\n" + str;

            }

        return code;

        }

    catch (e) { _alert(e); throw(e); }

    }

////////////////////////////////////////////////////////////////////////////////////////////

function parse_ref(ref)

    {

    try

        {

        var name = ref_name + (ref_numb?ref_numb:"");

        var code = "var " + name + " = new ActionReference();";

        while (1)

            {

            var ok = true;

            try { var type = ref.getForm(); } catch (e) { ok = false; }

            if (!ok) break;

            var str = "// UNNKOWN TYPE!";

            switch (type)

                {

                case ReferenceFormType.ENUMERATED: str = name + ".putEnumerated(" + k2s(ref.getDesiredClass()) + ", " + k2s(ref.getEnumeratedType()) + ", " + k2s(ref.getEnumeratedValue()) + ");"; break;

                case ReferenceFormType.CLASSTYPE:  str = name + ".putClass("      + k2s(ref.getDesiredClass()) + ");"; break;

                case ReferenceFormType.IDENTIFIER: str = name + ".putIdentifier(" + k2s(ref.getDesiredClass()) + ", " + ref.getIdentifier() + ");"; break;

                case ReferenceFormType.INDEX:      str = name + ".putIndex("      + k2s(ref.getDesiredClass()) + ", " + ref.getIndex()      + ");"; break;

                case ReferenceFormType.OFFSET:     str = name + ".putOffset("     + k2s(ref.getDesiredClass()) + ", " + ref.getOffset()     + ");"; break;

                case ReferenceFormType.NAME:       str = name + ".putName("       + k2s(ref.getDesiredClass()) + ", \"" + ref.getName()   + "\");"; break;

                case ReferenceFormType.PROPERTY:   str = name + ".putProperty("   + k2s(ref.getDesiredClass()) + ", " + k2s(ref.getProperty())  + ");"; break;

                }

            code += "\n" + str;

            try { ref = ref.getContainer(); } catch (e) { ok = false; }

            if (!ok) break;

            }

        return code;

        }

    catch (e) { _alert(e); throw(e); }

    }

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
LEGEND ,
Mar 21, 2018 Mar 21, 2018

Copy link to clipboard

Copied

Great script but I have problem to run it. I tried by 2 ways. First I put it to StartupScripts / Photoshop folder and reopened Photoshop. As it didn't work I tried the same by putting it to Presets / Scripts / Event Scripts Only. It didn't work as well. In both cases it was added to File / Scripts / Scripts Manager (in case of second one by me manually). / 'Evertything' was set.

I don't know maybe it's because now I'm in work at CS6 polish version / I tried on english CC2018 and it doesn't work too.

Edit: I changed ~/EventListener.log to ~/Desktop/EventListener.log and it works Where that has been saving before?

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
People's Champ ,
Mar 22, 2018 Mar 22, 2018

Copy link to clipboard

Copied

I kept the log on the desktop. The path can be checked as follows: alert (file.fsName).

It probably worked because I moved the desktop through the registry to another disk.

In general, the path "~/Desktop/EventListener.log" is more correct.

The script can be located anywhere, but not in the Startup Scripts folder.

Still need to remove the unnecessary function next_dsc(), next_lst() and next_ref() and replace _alert() with alert().

In plans, design each event as a separate function and track duplicates of stringIDToTypeID such as paint, good, grain, etc.

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
LEGEND ,
Mar 22, 2018 Mar 22, 2018

Copy link to clipboard

Copied

Amazing work - probably that will be best and fastest of all six (Script)EventListener converters there are available now!

Please, could you create separate topic for your script. I think this topic shouldn't be anymore continued with a staff that's not strictly refered to Tomas Sinkunas Clean SL. Users may want to give you some advices for next versions, however you are so experienced and have view at other 'cleaners' functionalities that your vision should be already more than clear

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
Enthusiast ,
Mar 22, 2018 Mar 22, 2018

Copy link to clipboard

Copied

I tried similar thing but I had problem that listening for "All " events changed output. I wasn't able to listen e.g. free transformation event. There was garbage code instead. It was good for most action but for some actions I couldn't get code. And it also wasn't in ScriptListener.log

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
People's Champ ,
Mar 22, 2018 Mar 22, 2018

Copy link to clipboard

Copied

Jarda Bereza 

 

I tried similar thing but I had problem that listening for "All " events changed output. I wasn't able to listen e.g. free transformation event. There was garbage code instead. It was good for most action but for some actions I couldn't get code. And it also wasn't in ScriptListener.log

This is some strange bug in CC2018 or feature.

I'll try to figure it out later.

 

On CS6, everything is OK.

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 ,
Mar 22, 2018 Mar 22, 2018

Copy link to clipboard

Copied

I tried the script but it gives me this error

with photoshop cc2014 and cc2018

aaa.png

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
LEGEND ,
Mar 22, 2018 Mar 22, 2018

Copy link to clipboard

Copied

Probably I had the same error before I did what I wrote in reply No. 114.

Also make sure you loaded script to Presets / Scripts / Event Scripts

And activated it from File / Scripts / Action Manager.

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 ,
Mar 22, 2018 Mar 22, 2018

Copy link to clipboard

Copied

I used the system suggested by Kukurykus

it worked well for me

but I noticed that cc2018 generates garbage in the code and I do not know how to clean up everything you have an idea?

this is an example

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

var idinvokeCommand = stringIDToTypeID( "invokeCommand" );

    var desc3 = new ActionDescriptor();

    var idcommandID = stringIDToTypeID( "commandID" );

    desc3.putInteger( idcommandID, 1139 );

    var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );

    desc3.putBoolean( idkcanDispatchWhileModal, true );

executeAction( idinvokeCommand, desc3, DialogModes.NO );

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 ,
Mar 22, 2018 Mar 22, 2018

Copy link to clipboard

Copied

Yes I consider that code garbage however  Kukurykus posted a link PS Scripting - check if layer link is temporary disabled

where "invokeCommand" may not always be unusable. The command id 1139 may be of use but not with my knowledge.    There is an option in Thomas Clean SL script that you can use to delete code produced by scriptlistener that to me seems to be garbage 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
Explorer ,
Mar 22, 2018 Mar 22, 2018

Copy link to clipboard

Copied

Kukurykus, the output of the cleaned AM-code via clipboard is a real improvement for me. I tried to code it myself when I tested the cleanSL-script in 2017 but I couldn't find the right way how to copy the cleaned code to the clipboard. Now it works perfectly. Thank you so much!

I would appreciate very much to get the raw AM-code from the clipboard into the script , so I could mark the interesting part in the SL logfile (or anywhere else) and store it into the clipboard and then start the script. I couldn't find anything equivalent to the systemCommand = 'pbcopy'.

Isn't it possible at all to copy the clipboard content to a variable in javascript?

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
LEGEND ,
Mar 22, 2018 Mar 22, 2018

Copy link to clipboard

Copied

You may post your ideas in Action Manager (Script Listener) code converter script! as here's a theard of Tomas Sinkunas.

 

I'm answering here last time, so if you have something to ask about my script, do it there please, however currently I don't develop this script and can't say when I might do it. Are you Windows user, because 'pbcopy' command is for Macintoshs.

 

I don't know. JavaScript is limited, but perhaps there's way to do it with VisualBasic (.vbs). So far I did such thing with system programming language autohotkey you can download. If you do not have: scite4ahk editor you may create .ahk script with Notepad. Open it and put inside this code:

 

FileAppend, %clipboard%, %A_ScriptDir%\clipboard.txt

 

Then save as "clipboard.ahk" (incl. double quotes). Finally RMB click on file and select 'Compile Script' to convert to .exe format. Then you can create .jsx script and save in the same folder (let's say on desktop as clipboard.jsx):

 

(fle = File($.fileName.slice(0, -3) + 'txt')).open('r')

cnt = fle.read(), fle.close(), fle.remove(), alert(cnt)

 

Regarding reading raw AM code you must figure it yourself, or post request in a topic you got link to...

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
Enthusiast ,
Mar 22, 2018 Mar 22, 2018

Copy link to clipboard

Copied

You can use Action Manager code for setting clipboard content.

var ktextToClipboardStr = stringIDToTypeID("textToClipboard");

var keyTextData = charIDToTypeID("TxtD");

var testStrDesc = new ActionDescriptor();

testStrDesc.putString(keyTextData, "ahoj");

executeAction(ktextToClipboardStr, testStrDesc, DialogModes.NO);

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
LEGEND ,
Mar 22, 2018 Mar 22, 2018

Copy link to clipboard

Copied

He wants clipboard to variable, not text to clipboard, otherwise I wouldn't write this all.

Additionally 'your' code what I remember didn't work in CS6, but started in EXTENDED.

BTW I forgot in .jsx file put this code on top (so in first of there lines there should be):

File($.fileName.slice(0, -3) + 'exe').execute(), $.sleep(100);

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