Copy link to clipboard
Copied
In continuation of the post Clean SL and at the request of the Kukurykus
I bring to your attention the script event_listener.jsx.
It allows you to write events as functions in the file ~/Desktop/EventListener.log.
The script needs to be copied to the ..\Presets\Scripts folder.
To activate it, you need to start it manually (It will be located in the menu beside "Script Events Manager").
To activate, click "Enable", to deactivate, click "Disable".
If you previously installed the notifiers in the Script Events Manager, it is desirable to clear them manually.
While this is the first version, but I think that the latter, too.
I do not see any prospects for further development.
Maybe someone will suggest ideas or he will start developing the script himself.
The script:
<javascriptresource>
<name>Script Events Listener...</name>
<category>scriptevents</category>
</javascriptresource>
var log_name = "~/Desktop/EventListener.log";
var dsc_name = "d";
var lst_name = "list";
var ref_name = "r";
var dsc_numb = 0;
var lst_numb = -1;
var ref_numb = -1;
var tab = " ";
var silent = false;
var events_CS6 = [ "All " ];
var events_CC = [
"TdT ","Avrg","ASty","Asrt","AccE","Add ","AdNs","AddT","Algn","AngS","AppI","BsRl","Btch","BtcF","Blr ","BlrM","Brdr","BrgC","CnvS","ChlC","ChnM",
"Chrc","Chrm","Cler","Cls ","Clds","ClrB","ClrH","ClrR","ClrP","CntC","Cntc","CnvM","copy","CpFX","CpyM","CpTL","Crql","CrtD","Crop","Crsh","Crst",
"Crvs","Cstm","cut ","CtTL","Ct ","DrkS","Dntr","DfnP","Dfrg","Dlt ","Dstt","Dslc","Dspc","DfrC","Dfs ","DfsG","dlfx","Dspl","Dstr","Draw","DryB",
"Dplc","DstS","Embs","Eqlz","Exch","Expn","Expr","Extr","Fct ","Fade","Fthr","Fbrs","Fl ","FlmG","Fltr","FndE","FltI","Flip","Frgm","Frsc","GsnB",
"getd","Gls ","GlwE","Grdn","GrMp","Grn ","GraP","GrpL","Grow","HlfS","Hd ","HghP","HsbP","HStr","ImgS","Impr","InkO","Intr","IntW","Invs","Invr",
"LnsF","Lvls","LghE","Lnk ","Mk ","Mxm ","Mdn ","Mrg2","MrgL","MSpt","MrgV","Mztn","Mnm ","Msc ","MscT","MtnB","move","NTSC","NGlw","Nxt ","NtPr",
"Ntfy","null","OcnR","Ofst","Opn ","Pnt ","PntD","PltK","past","PaFX","PstI","PstO","Ptch","Phtc","Pnch","Plc ","Plst","PlsW","Ply ","Pntl","Plr ",
"PstE","Pstr","Prvs","Prnt","PrfT","Prge","quit","RdlB","Rstr","RstT","RmvB","RmvL","RmvW","Rnm ","RplC","Rset","Rtcl","Rvrt","Rple","Rtte","RghP",
"save","slct","SlcC","setd","ShrE","Shrp","ShrM","Shr ","Shw ","Smlr","SmrB","Smth","SmdS","Slrz","Spt ","Sphr","SplC","Spng","SprS","StnG","Stmp",
"Stop","Strk","Sbtr","SbtF","Smie","TkMr","TkSn","TxtF","Txtz","Thrs","Tls ","TrnE","TrcC","Trnf","Trap","Twrl","Undr","undo","Ungr","Unlk","UnsM",
"Vrtn","Wait","WtrP","Wtrc","Wave","Wnd ","ZgZg",
"BacL","FilE","ColE","OpnU",
"rigidTransform",
"perspectiveWarpTransform",
"Adobe Camera Raw Filter",
"smartBrushWorkspace",
"focusMask",
];
if (!arguments.length)
{
var events = (parseInt(app.version)==13)?events_CS6:events_CC;
var d = new Window("dialog", "Event Listener 0.01")
d.orientation = "row";
d.spacing = 20;
d.margins = 20;
var b1 = d.add("button", undefined, "Enable");
var b2 = d.add("button", undefined, "Disable");
b1.onClick = function()
{
d.close();
for (var i = 0; i < events.length; i++) enable_notifier(events, $.fileName);
alert("Event Listener Enabled!", " ")
}
b2.onClick = function()
{
d.close();
for (var i = 0; i < events.length; i++) disable_notifier(events, $.fileName);
alert("Event Listener Disabled!", " ")
}
d.show();
}
if (arguments.length >= 2) main(arguments[0], arguments[1]);
//////////////////////////////////////////////////////////////////////////
function main()
{
try
{
var func_name = typeIDToStringID(arguments[1]);
if (!func_name) func_name = typeIDToChar(arguments[1]);
if (func_name.toLowerCase().indexOf("modalstate") >= 0) return;
if (func_name.toLowerCase().indexOf("invokecommand") >= 0) return;
if (func_name.toLowerCase().indexOf("togglebrushesflyout") >= 0) return;
var msg = null;
if (!silent)
{
msg = new Window("palette", "Event Listener", undefined, {independent:true} );
msg.preferredSize.width = 150;
msg.txt = msg.add("statictext", undefined, func_name);
msg.show();
}
var file = new File(log_name);
file.open("a");
file.writeln("///////////////////////////////////////////////////////////////////////////////");
file.writeln("function " + func_name + "_" + Math.random().toString().substr(2) + " ()");
file.writeln(tab + "{");
file.writeln(tab + "try {");
file.writeln(parse_desc(arguments[0]));
file.writeln(tab + tab + "executeAction(" + k2s(arguments[1]) + ", d, DialogModes.NO);");
file.writeln(tab + tab + "}");
file.writeln(tab + "catch (e) { throw(e); }");
file.writeln(tab + "}");
file.writeln("");
file.close();
if (msg)
{
msg.close();
msg = null;
}
}
catch (e) { _alert(e); }
}
//////////////////////////////////////////////////////////////////////////
function _alert(e)
{
if (e.number != 8007)
{
alert("Line: " + e.line + "\n\n" + e, "Bug!", true);
}
}
//////////////////////////////////////////////////////////////////////////
function enable_notifier(event_name, script_name, event_class)
{
try
{
for (var i = 0; i < app.notifiers.length; i++)
{
if (app.notifiers.event == event_name &&
File(app.notifiers.eventFile).fsName.toLowerCase() == File(script_name).fsName.toLowerCase())
{
if (!app.notifiersEnabled) app.notifiersEnabled = true;
return true;
}
}
app.notifiers.add(event_name, File(script_name), event_class);
app.notifiersEnabled = true;
return true;
}
catch (e) { _alert(e); return false; }
}
//////////////////////////////////////////////////////////////////////////
function disable_notifier(event_name, script_name, event_class)
{
try
{
var ret = false;
for (var i = 0; i < app.notifiers.length; i++)
{
if (app.notifiers.event == event_name &&
File(app.notifiers.eventFile).fsName.toLowerCase() == File(script_name).fsName.toLowerCase())
{
app.notifiers.remove();
ret = true;
}
}
if (!app.notifiers.length) app.notifiersEnabled = false;
return ret;
}
catch (e) { _alert(e); return false; }
}
//////////////////////////////////////////////////////////////////////////
function k2s(key)
{
try
{
var str = typeIDToStringID(key);
var chr = typeIDToCharID(key);
switch (chr)
{
case "Gd ": str = "guide"; break;
case "Grn ": str = "green"; break;
case "Grns": str = "greens"; break;
case "Pnt ": str = "point"; break;
case "Rds ": str = ""; break;
}
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 = (dsc_numb?"":(tab + tab)) + "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" + tab + tab + 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" + tab + tab + 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" + tab + tab + 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" + tab + tab + 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" + tab + tab + 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" + tab + tab + 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" + tab + tab + 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" + tab + tab + 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" + tab + tab + str;
try { ref = ref.getContainer(); } catch (e) { ok = false; }
if (!ok) break;
}
return code;
}
catch (e) { _alert(e); throw(e); }
}
Copy link to clipboard
Copied
I tried your script
it does not work for me use mac with photoshop cc2014 2018
this is the generated script
I create level
create curves
and set curves
///////////////////////////////////////////////////////////////////////////////
function make_09353293897584 ()
{
try {
var d = new ActionDescriptor();
var r = new ActionReference();
r.putClass(stringIDToTypeID("layer"));
d.putReference(stringIDToTypeID("null"), r);
d.putInteger(stringIDToTypeID("layerID"), 524);
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
}
catch (e) { throw(e); }
}
///////////////////////////////////////////////////////////////////////////////
function mergeVisible_00810609897599 ()
{
try {
var d = new ActionDescriptor();
d.putBoolean(stringIDToTypeID("duplicate"), true);
executeAction(stringIDToTypeID("mergeVisible"), d, DialogModes.NO);
}
catch (e) { throw(e); }
}
///////////////////////////////////////////////////////////////////////////////
function make_74433935759589 ()
{
try {
var d = new ActionDescriptor();
var r = new ActionReference();
r.putClass(stringIDToTypeID("adjustmentLayer"));
d.putReference(stringIDToTypeID("null"), r);
var d1 = new ActionDescriptor();
var d2 = new ActionDescriptor();
d2.putEnumerated(stringIDToTypeID("presetKind"), stringIDToTypeID("presetKindType"), stringIDToTypeID("presetKindDefault"));
d1.putObject(stringIDToTypeID("type"), stringIDToTypeID("curves"), d2);
d.putObject(stringIDToTypeID("using"), stringIDToTypeID("adjustmentLayer"), d1);
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
}
catch (e) { throw(e); }
}
///////////////////////////////////////////////////////////////////////////////
function set_11158893955871 ()
{
try {
var d = new ActionDescriptor();
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("adjustmentLayer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
d.putReference(stringIDToTypeID("null"), r);
var d1 = new ActionDescriptor();
d1.putEnumerated(stringIDToTypeID("presetKind"), stringIDToTypeID("presetKindType"), stringIDToTypeID("presetKindCustom"));
var list = new ActionList();
var d2 = new ActionDescriptor();
var r1 = new ActionReference();
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("composite"));
d2.putReference(stringIDToTypeID("channel"), r1);
var list1 = new ActionList();
var d3 = new ActionDescriptor();
d3.putDouble(stringIDToTypeID("horizontal"), 0);
d3.putDouble(stringIDToTypeID("vertical"), 0);
list1.putObject(stringIDToTypeID("point"), d3);
var d4 = new ActionDescriptor();
d4.putDouble(stringIDToTypeID("horizontal"), 91);
d4.putDouble(stringIDToTypeID("vertical"), 103);
list1.putObject(stringIDToTypeID("point"), d4);
var d5 = new ActionDescriptor();
d5.putDouble(stringIDToTypeID("horizontal"), 182);
d5.putDouble(stringIDToTypeID("vertical"), 222);
list1.putObject(stringIDToTypeID("point"), d5);
var d6 = new ActionDescriptor();
d6.putDouble(stringIDToTypeID("horizontal"), 255);
d6.putDouble(stringIDToTypeID("vertical"), 255);
list1.putObject(stringIDToTypeID("point"), d6);
d2.putList(stringIDToTypeID("curve"), list1);
list.putObject(stringIDToTypeID("curvesAdjustment"), d2);
d1.putList(stringIDToTypeID("adjustment"), list);
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("curves"), d1);
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
}
catch (e) { throw(e); }
}
///////////////////////////////////////////////////////////////////////////////
function select_47530803643167 ()
{
try {
var d = new ActionDescriptor();
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("RGB"));
d.putReference(stringIDToTypeID("null"), r);
d.putBoolean(stringIDToTypeID("makeVisible"), false);
executeAction(stringIDToTypeID("select"), d, DialogModes.NO);
}
catch (e) { throw(e); }
}
Copy link to clipboard
Copied
What's wrong? )
Copy link to clipboard
Copied
Nothing happens when I use it
to you the code I posted works?
Copy link to clipboard
Copied
I do not understand.
Maybe you forgot to put a call to the function you need from the log?
Copy link to clipboard
Copied
I noticed that if I delete the function
it works properly
try {
var d = new ActionDescriptor ();
var r = new ActionReference ();
r.putClass (stringIDToTypeID ("layer"));
d.putReference (stringIDToTypeID ("null"), r);
d.putInteger (stringIDToTypeID ("layerID"), 524);
executeAction (stringIDToTypeID ("make"), d, DialogModes.NO);
}
catch (e) {throw (e); }
Or if you call the function
it works properly
///////////////////////////////////////////////////////////////////////////////
function make_09353293897584 ()
{
try {
var d = new ActionDescriptor();
var r = new ActionReference();
r.putClass(stringIDToTypeID("layer"));
d.putReference(stringIDToTypeID("null"), r);
d.putInteger(stringIDToTypeID("layerID"), 524);
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
}
catch (e) { throw(e); }
}
make_09353293897584 ()
Copy link to clipboard
Copied
Dumb and Dumber.
Sorry
Copy link to clipboard
Copied
r-bin
you could enter the call to functions
in the script.
Thank you
Copy link to clipboard
Copied
I'll post an updated version later.
Copy link to clipboard
Copied
I'm having problems with raw camera filter
your script gives me this
d.putString(charIDToTypeID("CP_D"), "54650A341B5B5CCAE8442D0B43A92BCE");
d.putInteger(charIDToTypeID("PrVe"), 167772160);
d.putString(charIDToTypeID("Rtch"), "");
d.putString(charIDToTypeID("REye"), "");
d.putString(charIDToTypeID("LCs "), "");
d.putString(charIDToTypeID("Upri"), "<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c140 79.160451, 2017/05/06-01:08:21 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/"
crs:UprightVersion="151388160"
crs:UprightCenterMode="0"
crs:UprightCenterNormX="0.5"
crs:UprightCenterNormY="0.5"
crs:UprightFocalMode="0"
crs:UprightFocalLength35mm="35"
crs:UprightPreview="False"
crs:UprightTransformCount="6"/>
</rdf:RDF>
</x:xmpmeta>
");
d.putString(charIDToTypeID("GuUr"), "<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c140 79.160451, 2017/05/06-01:08:21 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/"
crs:UprightFourSegmentsCount="0"/>
</rdf:RDF>
</x:xmpmeta>
");
executeAction(stringIDToTypeID("Adobe Camera Raw Filter"), d, DialogModes.NO);
instead ScriptingListener
give me this
desc38.putString( idCP_D, """54650A341B5B5CCAE8442D0B43A92BCE""" );
var idPrVe = charIDToTypeID( "PrVe" );
desc38.putInteger( idPrVe, 167772160 );
var idRtch = charIDToTypeID( "Rtch" );
desc38.putString( idRtch, """""" );
var idREye = charIDToTypeID( "REye" );
desc38.putString( idREye, """""" );
var idLCs = charIDToTypeID( "LCs " );
desc38.putString( idLCs, """""" );
var idUpri = charIDToTypeID( "Upri" );
desc38.putString( idUpri, """<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c140 79.160451, 2017/05/06-01:08:21 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/"
crs:UprightVersion="151388160"
crs:UprightCenterMode="0"
crs:UprightCenterNormX="0.5"
crs:UprightCenterNormY="0.5"
crs:UprightFocalMode="0"
crs:UprightFocalLength35mm="35"
crs:UprightPreview="False"
crs:UprightTransformCount="6"/>
</rdf:RDF>
</x:xmpmeta>
""" );
var idGuUr = charIDToTypeID( "GuUr" );
desc38.putString( idGuUr, """<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c140 79.160451, 2017/05/06-01:08:21 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/"
crs:UprightFourSegmentsCount="0"/>
</rdf:RDF>
</x:xmpmeta>
""" );
executeAction( idAdobeCameraRawFilter, desc38, DialogModes.NO );
are missing "" ""
Copy link to clipboard
Copied
I'll fix it. )
Copy link to clipboard
Copied
How did you call the functions? With?
make_09353293897584 ()
mergeVisible_00810609897599 ()
make_74433935759589 ()
set_11158893955871 ()
select_47530803643167 ()
Copy link to clipboard
Copied
I tested your script and it works, but didn't check yet how that works for many possible operations. I guess it works very good Now in geppettol66959005 output I noticed d.putInteger(stringIDToTypeID("layerID"), 524); line. That is surely record generated by new Photoshop CC. In CS6 you had either name of layer or layer Index. I'm just wondering that code couldn't be used with other document that has the same set of layers, because certain layer doesn't have 524 ID anymore. Isn't it badly designed? If we wanted to use that code for other document (same kind and order of layers we had to change ID to Index 😕 If so the best would be if 'cleaner / converter' did that in its output, but I am not sure if I am correct about it?
function make_09353293897584 ()
{
try {
var d = new ActionDescriptor();
var r = new ActionReference();
r.putClass(stringIDToTypeID("layer"));
d.putReference(stringIDToTypeID("null"), r);
d.putInteger(stringIDToTypeID("layerID"), 524);
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
}
catch (e) { throw(e); }
}
Copy link to clipboard
Copied
Did you compare the output to ScriptingListenerJS.log?
I also noticed that especially on CS6 sometimes some events are skipped, especially: "set". The CC is better, but the "all" event works badly there. Therefore, it processes events only from the events_CC array.
Copy link to clipboard
Copied
Okey I tested that code I posted in reply No. 2 and I see there is no problem about, so all is okey
Copy link to clipboard
Copied
Updated version.
<javascriptresource>
<name>Script Events Listener...</name>
<category>scriptevents</category>
</javascriptresource>
var _version = "0.02";
var log_name = "~/Desktop/EventListener.log";
var max_data_len = 10000; // Trims data to this value if they are longer. For example, with toolRecording
var dsc_name = "d";
var lst_name = "list";
var ref_name = "r";
var dsc_numb = 0;
var lst_numb = -1;
var ref_numb = -1;
var tab = " ";
var silent = false;
var events_CS6 = [ "All " ];
var events_CC = ["TdT ", "Avrg", "Asrt", "Fbrs", "HsbP", "LghE", "Pnt ", "TxtF", "Vrtn", "BacL", "FilE", "ColE", "OpnU", "VnPt", "LqFy",
"Illustrator Export. This string makes me unique!",
"22C3EEBF-A978-4ca9-91DF-E4F0CCEE5ACE",
"733B7310-9259-48fd-8A07-24CF7521590D",
"4059cf7a-9304-11d3-bd8d-0060b0a13dc4",
"1CAB8255-B682-4EAD-8184-AC65030134D5",
"ffcb20ee-4c1f-11e5-885d-feff819cdc9f",
"12fb03a7-e9af-426a-8377-3d423d7303e6",
"8cba8cd6-cb66-11d1-bc43-0060b0a13dc4",
"0B71D221-F8CE-11d2-B21B-0008C75B322C",
"a0754df2-9c60-4b64-a940-6a2bb1102652",
"6f1c2cf5-4a97-4e32-8f59-f5d7a087adef",
"9AA9D7D6-C209-494A-CC01-4E7D926DA642",
"3caa3434-cb67-11d1-bc43-0060b0a13dc4",
"8a761c74-f362-4a1b-a3f7-e779ab319a08",
"e805a6ee-6d75-4b62-b6fe-f5873b5fdf20",
"CA37AEAF-6272-41F7-8258-F272711964E2",
"1F9021B1-5045-42E1-AE2A-7E504FAA8D50",
"cf34b502-2013-4d07-8431-1dfd634ee0cd",
"B20FB700-B96A-4C10-B666-8C9B9DEF594E",
"9AA9D7D6-C209-494A-BED9-4E7D926DA69F",
"08E8421B-976E-4E81-A964-AD754EDB4381",
"6F17BFA7-EFC8-40EA-B850-7B95ED8EA713",
"9D3174CE-045C-4B87-B7AE-40D8C3319780",
"0f9db13f-a772-4035-9020-840f0e5e2f02",
"808034C2-162D-481B-88D4-B3EF294EDE42",
"20489C30-9DB1-4DAD-B685-513A8C0543B9",
"SaveForWeb",
"Adobe Camera Raw Filter",
"CropPhotos0001",
"AdobeExposureMergeUI",
" JPEG 2000",
"CropPhotosAuto0001",
"AdobeScriptAutomation Scripts",
"WIAWizard0001",
"Adobe Camera Raw",
"export3DSingleMesh",
"set3DUnits",
"renderUVVertexColors",
"print3D",
"cancelPrint3D",
"print3DProperties",
"setPrint3DProperties",
"print3DUtilities",
"bake3DCrossSection",
"bakeFor3DPrinting",
"upload3DToSketchFab",
"set3DSkeletalAnimation",
"set3DFacialExpressionAnimation",
"GetBuiltInMixamoSearches",
"SearchMixamo",
"GetLastMixamoResults",
"GetMixamoThumbnailPath",
"ApplyMixamoPreset",
"GetMixamoParameters",
"SetMixamoParameter",
"sceneToGroup",
"set3DMeshGroupSwitch",
"set3DGroupSwitch",
"simplify3DModel",
"merge3DMaterials",
"repair3DModel",
"create3DFromDepthSolidExtrusion",
"create3DFromDepthTwoSidedSolidExtrusion",
"create3DFromRGBD",
"New3DRepoussePreset",
"Save3DRepoussePresets",
"Delete3DRepoussePreset",
"DeleteAll3DRepoussePresets",
"Restore3DRepoussePresets",
"Rename3DRepoussePresets",
"objectGroup",
"objectReorder",
"objectBake",
"replaceMesh",
"materialSwitch",
"objectUnGroup",
"objectInstance",
"objectReplicate",
"objectSceneNew",
"objectSceneNewFile",
"packTo3DGroundPlane",
"projectionPaintToggle",
"select3DInstances",
"select3DReference",
"center3DMesh",
"set3DPrintScale",
"add3DRigToMesh",
"convertJSONdescriptor",
"applyBrushFile",
"artboardFromLayerGroupEvent",
"artboardFromLayersEvent",
"brushSelectionModeAdd",
"brushSelectionModeRefine",
"brushSelectionModeReplace",
"brushSelectionModeSubtract",
"changePathDetails",
"clearAllGuides",
"clearCanvasGuides",
"clearSelectedArtboardGuides",
"conditional",
"convertColorToSpace",
"copyLayerCSS",
"copyLayerSVG",
"decoRenderFlame",
"decoRenderPictureFrame",
"decoRenderTree",
"definePatternFile",
"deleteTimeline",
"duplicateAudioClips",
"editArtboardEvent",
"enableExtendedNotification",
"fixMissingLinkedAssets",
"flushImageChangedEvents",
"focusMask",
"generate",
"generateAssets",
"generatorTrackingEnable",
"hitTest",
"jsonAction",
"collapseAllGroupsEvent",
"licensed",
"isolateLayers",
"deIsolateLayers",
"makerColorLookupLayerFromFile",
"makeFrameAnimation",
"makePatternLayerFromFile",
"makeTimeline",
"newArtboardGuidesFromTarget",
"newArtboardEvent",
"newDocPresetJSON",
"newGuideLayout",
"newGuidesFromTarget",
"nodeConnection",
"nodeMenuInitialize",
"nodeMenu",
"nodePluginInitialize",
"nodePlugin",
"oilPaint",
"packageFile",
"reorderFX",
"placedLayerConvertToEmbedded",
"placedLayerConvertToLinked",
"placedLayerEmbedAll",
"placedLayerRelinkToFile",
"placedLayerRelinkToLibraries",
"placedLayerReplaceMissing",
"placedLayerRevealInOS",
"placedLayerUpdateAllModified",
"placedLayerUpdateModified",
"progressFinish",
"progressStart",
"progressUpdate",
"pushToDesignLibraries",
"rasterizeAllPlaced",
"remapFonts",
"resetDocumentChanged",
"resolveFontsDialog",
"perspectiveWarpTransform",
"sanitizeFileForTemplate",
"saveBrushFile",
"sendLayerThumbnailToNetworkClient",
"sendLayerShapeToNetworkClient",
"sendDocumentInfoToNetworkClient",
"sendJSONToNetworkClient",
"setOverscrollMode",
"setPanZoom",
"setPlacedLayerComp",
"shapeClipboardOperation",
"smartBrushWorkspace",
"smartBrushClearSelectionEvent",
"smartBrushResetSelectionEvent",
"syncManageAcct",
"syncSettings",
"syncSettingsPush",
"syncSettingsPull",
"typekitMarketingDialog",
"textCharStyleImport",
"textPgphStyleImport",
"textLoadDefaultTypeStyles",
"textSaveDefaultTypeStyles",
"textThumbnail",
"textToClipboard",
"thumbnailStyleFile",
"timelineEnable3DTracksKeys",
"toolRecording",
"undoWhile3DPainting",
"unzip",
"writePatternToFile",
"FuntaFormat",
"exportDocumentAsFileTypePressed",
"exportSelectionAsFileTypePressed",
"exportDocumentAsDialog",
"exportSelectionAsDialog",
"framedGroupFromLayerGroupEvent",
"framedGroupFromLayersEvent",
"newFramedGroupEvent",
"editFramedGroupEvent",
"autoCutout",
"ImportPanorama",
"ExportPanorama",
"create3DFromPanorama",
"key3DState",
"key3DObjectSelect",
"keyGetSelected3DObject",
"MixamoNotifier",
"keyMapClass",
"adaptCorrectTones",
"autoFixCorrectTones",
"jumpto",
"setTimelineTransitionProperties",
"setVideoClipVideoProperties",
"setVideoClipAudioProperties",
"setAudioClipProperties",
"32BitPreviewOptions",
"set3DGlobalAmbient",
"set3DBackgroundType",
"set3DBackgroundCount",
"set3DDisableColorLinearization",
"add3DLayerFromFile",
"open3DLayerTexture",
"save3DTextures",
"export3DModel",
"createPathFrom3D",
"reload3DModel",
"toggle3DTexture",
"resumeFinal3DRender",
"render3DSelection",
"splitRepousseMesh",
"toggle3DTextures",
"create3DPostcard",
"create3DTiledPainting",
"createVolume",
"set3DLightImageType",
"insertGroundPlane",
"3DRenderQualityPaint",
"3DRenderQualityModel",
"3DRenderQualityARTDraft",
"3DRenderQualityARTFinal",
"renderUVWireframe",
"renderUVShaded",
"renderUVNormalMap",
"renderUVBrushStrokes",
"set3DCamera",
"set3DObjectPosition",
"set3DCrossSection",
"set3DLightMode",
"set3DRenderMode",
"set3DEngine",
"set3DPaintType",
"set3DTransferFunction",
"add3DView",
"delete3DView",
"add3DObjectPosition",
"delete3DObjectPosition",
"set3DLightSwitch",
"set3DLightPosition",
"set3DLightDirection",
"set3DLightType",
"set3DLightColor",
"set3DLightHotspotAngle",
"set3DLightFalloffAngle",
"set3DLightInnerRadius",
"set3DLightOuterRadius",
"set3DLightIntensity",
"set3DLightCastsShadowsSwitch",
"set3DLightAttenuationSwitch",
"set3DLightAttenuationType",
"set3DLightAttenuationCoeff",
"set3DLightSoftShadows",
"set3DMeshPosition",
"set3DGroupPosition",
"set3DMeshAlignmentEdges",
"set3DMeshAlignmentCenters",
"set3DMeshDistribution",
"set3DMeshSwitch",
"set3DMeshShadowCatcher",
"set3DMeshShadowOpacity",
"set3DMeshShadowCasting",
"set3DMeshShadowInvisible",
"set3DMaterialSwitch",
"set3DMaterialScalar",
"set3DMaterialColor",
"set3DMaterialTexturePath",
"set3DMaterialTextureInfo",
"set3DPaintFalloff",
"hideAll3DSelected",
"hideTop3DSelected",
"hide3DEnclosedOnly",
"revealAll3D",
"invert3DSelected",
"paint3DDiffuse",
"paint3DEnvironment",
"paint3DBump",
"paint3DSpecular",
"paint3DOpacity",
"paint3DShininess",
"paint3DSelfIllumination",
"paint3DReflection",
"paint3DNormal",
"renderSettings3D",
"reparameterize3DModel",
"create3DFromDepthPlane",
"create3DFromDepthTwoSidedPlane",
"create3DFromDepthCylinder",
"create3DFromDepthSphere",
"create3DFromRepousseText",
"create3DFromRepousseWorkPath",
"create3DFromRepousseSheetMask",
"create3DFromRepousseAISO",
"create3DFromRepousseSelection",
"createConstraintFromWorkPath",
"createConstraintFromSelection",
"repousseInflationSide",
"repousseBevelSide",
"repousseInflationHeight",
"repousseInflationAngle",
"repousseBevelWidth",
"repousseBevelAngle",
"repousseBevelCountour",
"repousseExtrusionHeight",
"repousseExtrusionXAngle",
"repousseExtrusionYAngle",
"repousseExtrusionXYAngle",
"repousseExtrusionScale",
"repousseExtrusionTwist",
"repousseExtrusionOrigin",
"repousseExtrusionTextureType",
"repousseExtrusionShear",
"repousseMeshQuality",
"repousseConstraintType",
"repousseConstraintHeight",
"repousseConstraintAngle",
"repousseConstraintSide",
"repousseConstraintDelete",
"repousseConstraintPosition",
"repoussePreset",
"repousseNewPaths",
"repousseLoadPresets",
"repousseReplacePresets",
"objectDelete",
"objectNew",
"objectRename",
"add3DLightsFromPreset",
"delete3DLightsPreset",
"addPathToRepousse",
"dropTo3DGroundPlane",
"replace3DLightsFromPreset",
"replace3DMaterialFromPreset",
"save3DLightsToPreset",
"select3DPaintable",
"browse3DOnline",
"autoHide3D",
"New3DMaterialPreset",
"Save3DMaterialPresets",
"Load3DMaterialPresets",
"Replace3DMaterialPresets",
"Delete3DMaterialPreset",
"DeleteAll3DMaterialPresets",
"Restore3DMaterialPresets",
"Rename3DMaterialPresets",
"addAudioClipsToTimeline",
"addClipsToTimeline",
"addLayerFromFile",
"addLayerFromViewlessDoc",
"addTimelineTransition",
"closeViewlessDocument",
"colorLookup",
"Dicom",
"getTransforms",
"GIFFormat",
"openViewlessDocument",
"ID",
"JPEGTileExport",
"NTSCColors",
"NTSC",
"PDFExport",
"PSOpenFileDialog",
"accentedEdges",
"adaptCorrect",
"addLayerTogroupByDrag",
"addNoise",
"add",
"addBlankVideoLayer",
"addTo",
"addVideoLayer",
"align",
"alignment",
"angledStrokes",
"animationFrameActivate",
"animationFrameExtendSelection",
"animationFramesFromLayers",
"animationFramesToLayers",
"animationMatchLayer",
"animationPasteFrames",
"animationSelectAll",
"animationTween",
"applyComp",
"applyImageEvent",
"applyImageStackPluginRenderer",
"applyLocking",
"apply",
"applyStyle",
"assignProfile",
"autoFixCorrect",
"bMPFormat",
"basRelief",
"batchFromDroplet",
"batch",
"surfaceBlur",
"blackAndWhite",
"blurEvent",
"blurMethod",
"blurMore",
"border",
"boxblur",
"brightnessContrast",
"brightnessEvent",
"bringToFront",
"canvasSize",
"centerCropMarks",
"chalkCharcoal",
"channelMixer",
"charcoal",
"chrome",
"clearBrushControls",
"clearEvent",
"clearRuler",
"clearStyle",
"clearWarning",
"close",
"clouds",
"colorBalance",
"colorHalftone",
"colorPalette",
"colorRange",
"colorSampler",
"coloredPencil",
"combine",
"conteCrayon",
"contract",
"convertMode",
"convertAnimation",
"convertTimeline",
"convertToProfile",
"copyBrushTexture",
"copyEffects",
"copyEvent",
"copyKeyframes",
"copyMerged",
"copyToLayer",
"countAuto",
"countClear",
"countAdd",
"countDelete",
"countMove",
"countColor",
"countGroupVisible",
"countGroupMarkerSize",
"countGroupFontSize",
"countRenameGroup",
"countAddGroup",
"countDeleteGroup",
"countSetCurrentGroup",
"craquelure",
"createDroplet",
"createDuplicate",
"Crop",
"crosshatch",
"crystallize",
"curves",
"customPattern",
"custom",
"cut",
"cutToLayer",
"cutout",
"darkStrokes",
"decontaminate",
"deInterlace",
"dePosterize",
"defineBrush",
"defineCustomShape",
"definePattern",
"defineSprayer",
"defringe",
"deleteAllAnnot",
"deleteAudioClips",
"deleteFrame",
"deleteMeasurements",
"delete",
"deleteTransitions",
"denoise",
"desaturate",
"deselect",
"despeckle",
"destWhiteMax",
"differenceClouds",
"diffuseGlow",
"diffuse",
"disable",
"disableLayerFX",
"disableLayerStyle",
"disableSingleFX",
"displace",
"distort",
"distortion",
"distribute",
"distribution",
"divide",
"documentTimelineSettings",
"Draw",
"dryBrush",
"duplicateFrame",
"duplicate",
"dustAndScratches",
"editComment",
"editInImageReady",
"editVariables",
"emboss",
"enable",
"equalize",
"exchange",
"excludeIntersection",
"expand",
"exportDataSet",
"exportMeasurements",
"export",
"exportTimelineComments",
"exposure",
"extractWorkArea",
"extrude",
"facet",
"Fade",
"feather",
"Fl ",
"filmGrain",
"filter",
"findEdges",
"findReplace",
"flattenImage",
"Flip",
"floatWindow",
"fragment",
"fresco",
"gaussianBlur",
"get",
"glass",
"glowingEdges",
"gradientClassEvent",
"gradientMapEvent",
"grain",
"graphicPen",
"green",
"gridMinor",
"groupEvent",
"Grow",
"halftoneScreen",
"headlightsLog",
"headlightsInfo",
"healJPEG",
"healSelection",
"Hd ",
"highPass",
"hueSaturation",
"imageSize",
"imageStackConvertSmartObject",
"importAnnots",
"importDataSets",
"import",
"importVideoTapestry",
"importVideoToLayers",
"inkOutlines",
"insertBlankFrame",
"interfaceIconFrameDimmed",
"interfaceWhite",
"interlace",
"interpolation",
"interpretFootage",
"intersect",
"intersectWith",
"inverse",
"invert",
"groupLayersEvent",
"ungroupLayersEvent",
"lensFlare",
"levels",
"liftWorkArea",
"lightFilterLightingEffects",
"lightFilterExtractLight",
"lightFilterExtractColor",
"lightFilterGradient",
"lightFilterGradientMagnitude",
"Lnk ",
"linkSelectedLayers",
"enableLayerLink",
"disableLayerLink",
"selectAllLayers",
"selectNoLayers",
"findLayers",
"showAlteredVideo",
"hideAlteredVideo",
"makeFramesFromLayers",
"makeLayersFromFrames",
"Mk ",
"manual",
"matchColor",
"maximumQuality",
"maximum",
"measurementScale",
"measurementScaleMarker",
"median",
"menuItemClass",
"mergeAlignedLayers",
"mergeChannels",
"mergeLayersNew",
"mergeLayers",
"mergeSpotChannel",
"mergeVisible",
"mezzotint",
"minimum",
"mosaicPlugin",
"mosaic",
"motionBlur",
"move",
"moveAllTime",
"moveInTime",
"moveKeyframes",
"moveOutTime",
"moveStartTime",
"moveWorkArea",
"neonGlow",
"networkEventSubscribe",
"networkEventUnsubscribe",
"neutralizeColor",
"newPlacedLayer",
"Nxt ",
"nextFrame",
"nextKeyframe",
"notePaper",
"notify",
"null",
"oceanRipple",
"offset",
"Opn ",
"paintDaubs",
"paletteKnife",
"pasteEffects",
"pasteInto",
"pasteKeyframes",
"pasteOutside",
"paste",
"patchSelection",
"recomposeSelection",
"patchwork",
"perspectiveCrop",
"photoFilter",
"photocopy",
"pinch",
"placeEvent",
"placeMeasurementScaleMarker",
"placedLayerMakeCopy",
"placedLayerEditContents",
"placedLayerExportContents",
"placedLayerReplaceContents",
"plaster",
"plasticWrap",
"Ply ",
"playbackStrokeFromFile",
"pointillize",
"polar",
"posterEdges",
"posterization",
"posterize",
"previous",
"previousFrame",
"previousKeyframe",
"printOneCopy",
"print",
"profileToProfile",
"proofSetup",
"purge",
"quit",
"radialBlur",
"rasterizeAll",
"rasterizeLayer",
"vectorStrokeToFill",
"rasterizeLinked",
"rasterizePlaced",
"rasterize",
"rasterizeTypeLayer",
"rasterizeVideo",
"recapture",
"recordMeasurements",
"refineSelectionEdge",
"reloadFrame",
"removeBlackMatte",
"removeClipMotionProperties",
"removeLayerMask",
"removeWhiteMatte",
"rename",
"replaceColor",
"replaceFootage",
"replace",
"replaceAudioClip",
"replaceSubstitutes",
"resetFromComp",
"resetGPUStats",
"reset",
"resetDocumentFormatStr",
"resize",
"restoreAllFrames",
"restoreFrame",
"reticulation",
"revealAll",
"reverse",
"revert",
"rigidTransform",
"blurbTransform",
"ripple",
"rotateEventEnum",
"roughPastels",
"shapeBlur",
"save",
"scaleEffectsEvent",
"scaleKeyframes",
"select",
"selectSimilarLayers",
"selectiveColor",
"selectLinkedLayers",
"sendDocumentThumbnailToNetworkClient",
"separationSetup",
"set",
"setClipMotionProperties",
"setTransitionDuration",
"sharpenEdges",
"sharpenMore",
"sharpen",
"sharpness",
"shearEd",
"shear",
"showColorPicker",
"showFileBrowserPalette",
"showMiniBridge",
"Shw ",
"similar",
"smartBlur",
"smartSharpen",
"smoothness",
"smudgeStick",
"solarize",
"spatter",
"spellCheck",
"spherize",
"splitChannels",
"splitVideoLayer",
"sponge",
"sprayedStrokes",
"stainedGlass",
"stamp",
"getGPUStats",
"getGPUInfo",
"startPaintProfiling",
"startStrokeRecording",
"stopPaintProfiling",
"stopStrokeRecording",
"Stop",
"stroke",
"subtractFrom",
"subtract",
"sumie",
"supplementalCategories",
"systemCall",
"takeMergedSnapshot",
"takeSnapshot",
"targaFormat",
"target",
"texturizer",
"thresholdClassEvent",
"tiles",
"togglePalettes",
"tornEdges",
"traceContour",
"transform",
"Trap",
"trim",
"trimDocumentToWorkArea",
"twirl",
"underpainting",
"undoEvent",
"ungroup",
"unlink",
"unlinkSelectedLayers",
"unsharpMask",
"updateLayouts",
"updatePlacedLayer",
"vibrance",
"Wait",
"waterPaper",
"watercolor",
"Wave",
"Wnd ",
"workspaceMenu",
"zigZag",
"helpLauncher",
]
if (!arguments.length)
{
var events = (parseInt(app.version)==13)?events_CS6:events_CC;
var d = new Window("dialog", "Event Listener " + _version)
d.orientation = "row";
d.spacing = 20;
d.margins = 20;
var b1 = d.add("button", undefined, "Enable");
var b2 = d.add("button", undefined, "Disable");
b1.onClick = function()
{
d.close();
for (var i = 0; i < events.length; i++) enable_notifier(events, $.fileName);
alert("Event Listener Enabled!", " ")
}
b2.onClick = function()
{
d.close();
for (var i = 0; i < events.length; i++) disable_notifier(events, $.fileName);
alert("Event Listener Disabled!", " ")
}
d.show();
}
if (arguments.length >= 2) main(arguments[0], arguments[1]);
//////////////////////////////////////////////////////////////////////////
function main()
{
try
{
var func_name = typeIDToStringID(arguments[1]);
if (!func_name) func_name = typeIDToCharID(arguments[1]);
if (func_name.toLowerCase().indexOf("modalstate") >= 0) return;
if (func_name.toLowerCase().indexOf("invokecommand") >= 0) return;
if (func_name.toLowerCase().indexOf("togglebrushesflyout") >= 0) return;
func_name = func_name.replace(/^\s+/g, "");
func_name = func_name.replace(/\s+$/g, "");
func_name = func_name.replace(/\s/g, "_");
var msg = null;
if (!silent)
{
msg = new Window("palette", "Event Listener", undefined, {independent:true} );
msg.preferredSize.width = 150;
msg.txt = msg.add("statictext", undefined, func_name);
msg.show();
}
var file = new File(log_name);
file.open("a");
file.writeln("///////////////////////////////////////////////////////////////////////////////");
file.writeln("(function " + func_name + "_" + Math.random().toString().substr(2) + "()");
file.writeln(tab + "{");
file.writeln(tab + "try {");
file.writeln(parse_desc(arguments[0]));
file.writeln(tab + tab + "executeAction(" + k2s(arguments[1]) + ", d, DialogModes.NO);");
file.writeln(tab + tab + "}");
file.writeln(tab + "catch (e) { if (e.number!=8007) { alert(\"Line: \"+e.line+\"\\n\\n\"+e,\"Bug!\",true); throw(e); } }");
file.writeln(tab + "}");
file.writeln(")();");
file.writeln("");
file.close();
if (msg)
{
msg.close();
msg = null;
}
}
catch (e) { _alert(e); }
}
//////////////////////////////////////////////////////////////////////////
function _alert(e)
{
if (e.number != 8007)
{
alert("Line: " + e.line + "\n\n" + e, "Bug!", true);
}
}
//////////////////////////////////////////////////////////////////////////
function enable_notifier(event_name, script_name, event_class)
{
try
{
for (var i = 0; i < app.notifiers.length; i++)
{
if (app.notifiers.event == event_name &&
File(app.notifiers.eventFile).fsName.toLowerCase() == File(script_name).fsName.toLowerCase())
{
if (!app.notifiersEnabled) app.notifiersEnabled = true;
return true;
}
}
app.notifiers.add(event_name, File(script_name), event_class);
app.notifiersEnabled = true;
return true;
}
catch (e) { _alert(e); return false; }
}
//////////////////////////////////////////////////////////////////////////
function disable_notifier(event_name, script_name, event_class)
{
try
{
var ret = false;
for (var i = 0; i < app.notifiers.length; i++)
{
if (app.notifiers.event == event_name &&
File(app.notifiers.eventFile).fsName.toLowerCase() == File(script_name).fsName.toLowerCase())
{
app.notifiers.remove();
ret = true;
}
}
if (!app.notifiers.length) app.notifiersEnabled = false;
return ret;
}
catch (e) { _alert(e); return false; }
}
//////////////////////////////////////////////////////////////////////////
function k2s(key)
{
try
{
var str = typeIDToStringID(key);
var chr = typeIDToCharID(key);
switch (chr)
{
case "Gd ": str = "guide"; break;
case "Grn ": str = "green"; break;
case "Grns": str = "greens"; break;
case "Pnt ": str = "point"; break;
case "Rds ": str = ""; break;
case "Intr": str = ""; break;
}
if (str) return "stringIDToTypeID(\"" + str + "\")";
else if (chr) return "charIDToTypeID(\"" + chr + "\")";
else return "Bug!";
}
catch (e) { throw(e); }
}
////////////////////////////////////////////////////////////////////////////////////////////
function dat(s)
{
try
{
var ret = "";
var len = s.length;
if (len > max_data_len)
{
ret = "/* real data length = " + s.length + ", truncated to " + max_data_len + "*/ ";
len = max_data_len;
}
ret += "String.fromCharCode(";
for (var i = 0; i < len; 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 src(s)
{
try
{
s = s.toSource()
s = s.replace(/^\(new String\("/, "");
s = s.replace(/"))$/, "");
return s;
}
catch (e) { throw(e); }
}
//////////////////////////////////////////////////////////////////////////
function parse_desc(desc)
{
try
{
var name = dsc_name + (dsc_numb?dsc_numb:"");
var code = (dsc_numb?"":(tab + tab)) + "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" + tab + tab + 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" + tab + tab + 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" + tab + tab + 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) + ", \"" + src(desc.getString(key)) + "\");"; break;
case DescValueType.ALIASTYPE: str = name + ".putPath(" + k2s(key) + ", new File(\"" + src(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" + tab + tab + 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" + tab + tab + 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" + tab + tab + 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" + tab + tab + 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(" + "\"" + src(list.getString(i)) + "\");"; break;
case DescValueType.ALIASTYPE: str = name + ".putPath(" + "new File(\"" + src(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" + tab + tab + 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()) + ", \"" + src(ref.getName()) + "\");"; break;
case ReferenceFormType.PROPERTY: str = name + ".putProperty(" + k2s(ref.getDesiredClass()) + ", " + k2s(ref.getProperty()) + ");"; break;
}
code += "\n" + tab + tab + str;
try { ref = ref.getContainer(); } catch (e) { ok = false; }
if (!ok) break;
}
return code;
}
catch (e) { _alert(e); throw(e); }
}
EDIT:
Was updated. See reply Re: Script Events Listener
Copy link to clipboard
Copied
I found not once that using event listener I have problem with more than few documents opened from Windows or from Windows by Photoshop (manually as well). When event listener is turned on it seems to open them in correct order but then when all are already opened script listener activates them all again (one by one). That would be after all acceptable, but problem is when they are beeing reactivated it happens in other order than when they are beeing opened. Sometimes it's same order, but mostly differs slightly and other time quite different.
Generally that order is random, and sometimes they even are beeing opened not in the alphabetical order. What's wierd when I open one document and then change mode to Full Screen to open next files (still when Script listener is tunred on), then their order is kept as it should.
Saying Script Listener I don't mean your script but generally commands available in Photoshop scripting. I tried to solve it somehow but all my attempts failed. So I started to search for similar problem on this forum and I ended up in this theard. I tried your script (from reply No. 15) and I found the same problem
When your script is enabled (in CC 2018) please open (about 6 - 10) differently named files from the same location and tell me is their order the same as on disk when you look at them from Windows?
If you understand me and see the same problem, do you know why it happens and how to solve it?
You may also test it with line 866 changed to:
if (arguments.length >= 2) alert(activeDocument.name), main(arguments[0], arguments[1]);
Copy link to clipboard
Copied
Files open and remain open in the same sequence that I see in the window for opening files (in the same sorting as specified in the window). Another thing is that events after opening the last file are sent by Photoshop arbitrarily. This can be seen in the event_listener log or in ScriptingListenerJS.log for the ScriptListener.8li plugin. Perhaps this is a feature of Photoshop. I do not see what it can interfere with.
Copy link to clipboard
Copied
So I understand you noticed the same problem. After opening all files, event listener reactivates them in different order.
The only cumbersome workaround I found is to add a command to activate them all again (starting from first opened to last one) each time after another of them is already opened. It works the way they are opened normally, but then each time Event Listener activates arbitary opened file it sort them from first to last one order.
It's not good solution because that additional sorting happens for each file (so is time-consuming for many files, and visually that looks bad), and if there were already opened files in Photoshop which order was changed by us manually then the additional sorting files by their index is undesired behaviour.
If you don't completetly understand that I write now and need some examples, I am going to provide them, but if you understand it do you know at least other workaround to solve it?
For example do you think that would be possible that after opening by Photohsop all files the Event Listener ignores all of them beside last one?
Ps. I may also post very simple script, as the problem is not literally connected to your script but behaviour of event listener implemented to Photoshop scripting.
Copy link to clipboard
Copied
This does not event_listener "reactivates" them. This is Photoshop. Instead of the event_listener script, you can assign any script or action to the "Opn " command and get the same result too.
The same incorrect opening sequence is present in ScriptingListenerJS.log.
Copy link to clipboard
Copied
Here is example:
1) I created .jpg files: a, b, c, d, e, f, and saved them on desktop
2) then by Ps I opened them all at once (without custom event)
3) they are always sorted in alphabetical order, so: a, b, c, d, e, f
4) when I check ScriptListener log they usually have other order, like for ex.: c, e, b, d, f, a
The conclusion is, not Photoshop but ScriptListener plugin records other (arbitary) order of them.
Now I created one-line script: alert(activeDocument.name), that I named 'one-line.jsx' and saved to:
'Presets\Scripts\Event Scripts Only' of Photoshop folder
After I relaunched Photoshop I enabled new 'Open' event from 'File / Scripts / Scripts Events Manager'
Then I repeated 4 steps from beginning of this post.
In first instance they all were opened in alphabetical order, then arbitarily each of them was activated while name alerted.
After each alert I could notice there was added new record in ScriptListener.log - so not right after openning them all.
I did also experiment where I created new document, changed mode to Full Screen, then pressed Ctrl-O and selected those files to open. 'One-line.jsx' script was alerting them in arbitary order, but when all were opened and I changed mode back to Normal, they were sorted alphabeticaly. I guess it's not possible to enforce screen mode to full after opening first document.
So:
1) Photoshop opens them corectely
2) ScriptListener records in arbitary order
3) if Event is enabled they are activated again in arbitary order too
I also tried to open them not directly from Photoshop, but just from Windows or by Bridge. It did not help.
I also removed ScriptListener Plugin and repeated above points. It still activated documents in wrong order.
The final conclusion is that Photoshop Event Listener code is screwed up, isn't it?
Do you know how to access source code of 'Ps Event Listener' that I can perhpas fix?
If that is not possible would you propose some workaround documents were activated correctly when 'Event' is enabled?
Copy link to clipboard
Copied
What are you going to fix in the ScriptListener plugin? Need to fix photoshop )).
Write to any Action opening multiple files. You will see that the sequence will be broken. And at what here the ScriptListener plugin or my script?
I can not understand what this behavior bothers you?
Copy link to clipboard
Copied
Hmmm I mentioned in my post that I deleted ScriptListener plugin, I mean that from 'Plugin' folder of main Photoshop folder. So it's not about ScriptListener plugin but some other 'listener' that is part of Photoshop.
I noticed that Photoshop isn't broken like you say, because when you open a, b, c, d, e, f files they are opening in alphabetical order, aren't they? Only when you enable 'Event' to listen files you open, their order is going to be changed.
So I don't want to fix ScriptListener plugin as I see it doesn't affect wrong order of files, but part of Photoshop that is responsible for listening (when listening is enabled).
I also don't refer this problem directly to your script. I explained before it's not about your script, but similar problem that I noticed occurs also in your script.
I gave already example of script to test the problem I met, you put to EventsScriptOnly folder: alert(activeDocument.name)
however if you leave script empty, but enabled from Event Scripts Manager the effect will be the same. 'Alert' had only to help to notice that order is wrong.
Probably I don't understand you, but if Photoshop is broken then why when you open files without enabled event listener (not yours) they are opened in correct order?
That bothers me as from time to time I still meet this problem by occasion of some scripts and I'm tired of it enough now. So I want some workaround at least...
Copy link to clipboard
Copied
If the previous version was in the "Enabled" state, then it must be done "Disabled", before installing a new script.
Copy link to clipboard
Copied
I find this script very useful and I like to have the functions available in ExtendScript Toolkit so with the following script it can load the log into a new window.
//file location =
// C:\Program Files (x86)\Adobe\Adobe ExtendScript Toolkit CC\Required
extrasESTK = {};
extrasESTK.menus = {};
try {
extrasESTK.menus.extras = new MenuElement( "menu", "Extra", "at the end of menubar", "extrasESTK" );
extrasESTK.menus.rbin= new MenuElement( "command", "Event Listener Log", "at the end of extrasESTK", "extrasESTK/eventLog" );
} catch ( e ) {alert( e );}
extrasESTK.menus.rbin.onSelect =function(){
var file = new File("~/Desktop/EventListener.log");
file.open("r");
var data = file.read();
file.close();
docMgr.create("Log", data + '\n');
}
A restart of ExtendScript is required to pick up the new script.
A new menu Extra will be created.