Copy link to clipboard
Copied
I wish we could directly set the Thumbnail inside Layer Panel with the help of a script.
Sadly the listener doesn't record the setting of the Thumbnail Size, it only records the call of the Layer panel options .
I already found the helpful code below inside this post : get/set "Add Mask By Default" via AM?
but when i run the code, ESTK responds with the error "this functionnality may not be available in this versin of PS"
var ref = new ActionReference();
ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("layerThumbnailSize"));
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);
var layerThumbnailSize = typeIDToStringID(desc.getEnumerationValue(stringIDToTypeID("layerThumbnailSize")));
alert(layerThumbnailSize);
So, any help is welcome...
The scriptlistners does record what I call junk code for some things you do in Photoshop that just does not work in scripts. There is a script in the forum that can clean scriptlistener code (Clean SL)script to make it easer to read and use. I ask the author to add a remove junk code button to remove statement I consider junk. He did and made is easy foe me to add additional statments type to be removed.
Here I set the layers panel thumbnails size. Scriptlistner recorded 3 Action manage
...Copy link to clipboard
Copied
The scriptlistners does record what I call junk code for some things you do in Photoshop that just does not work in scripts. There is a script in the forum that can clean scriptlistener code (Clean SL)script to make it easer to read and use. I ask the author to add a remove junk code button to remove statement I consider junk. He did and made is easy foe me to add additional statments type to be removed.
Here I set the layers panel thumbnails size. Scriptlistner recorded 3 Action manager steps. From that none are useable.
Clean that code it easy to see its for the layers panel
However if you first remove what I consider junk code you come up empty.
Copy link to clipboard
Copied
If I understand you well, there is nothing more to add ...
Thanks JJMack for your useful answer.
Copy link to clipboard
Copied
r-bin​ answers correctly to your qeuestion. However I don't know is setting size of Thumbnail also possible beside reading it in later releases, like some settings I found ScriptListener doesn't write they were set but can be set by using ActionManager.
Copy link to clipboard
Copied
Which version of Photoshop?
You need CC2018 (everything works there) or at least 2015.5 (not sure).
Copy link to clipboard
Copied
CS6 version ... so it seems like my wish will not become reality !
Copy link to clipboard
Copied
CS6 you can only
runMenuItem(stringIDToTypeID("layersPaletteOptions"))
Copy link to clipboard
Copied
also usefull
runMenuItem(stringIDToTypeID("adjustmentAddMask"))
Copy link to clipboard
Copied
What preconditions in Photoshop need to be met that code with 'adjustmentAddMask' worked?
Copy link to clipboard
Copied
What are you interested in?
Create any adjustment layer. If it is created without a mask, and you need a mask, run this menu. The same applies when the layer is created with a mask and you need it without.
Copy link to clipboard
Copied
It doesn't work for me in CC2018 after adding Adjustement layer of any kind, like Levels or Color Balance for example with/out mask. It doesn't add/remove mask to/from Adjustement Layer when it's selected. What I'm doing wrong? 😕
Copy link to clipboard
Copied
set_add_mask(false)
///////////////////////////////////////////////////////////////////////////////
function set_add_mask(state)
{
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();
d1.putObject(stringIDToTypeID("type"), stringIDToTypeID("levels"), d2);
d.putObject(stringIDToTypeID("using"), stringIDToTypeID("adjustmentLayer"), d1);
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("hasUserMask"));
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
if (executeActionGet(r).getBoolean(stringIDToTypeID("hasUserMask")) == state)
{
activeDocument.activeLayer.remove();
return;
}
activeDocument.activeLayer.remove();
runMenuItem(stringIDToTypeID("adjustmentAddMask"));
}
catch (e) { throw(e); }
}
upd.
In CC2018 there is a way easier
Copy link to clipboard
Copied
It creates layer and adds a mask to it, then remove them. Still 'adjustmentAddMask' doesn't do anything at end of code 😕
Copy link to clipboard
Copied
Read the post on the link at the beginning of the topic
Copy link to clipboard
Copied
I see what it does now - un/check menu item in Adjustement panel. I wrongly thought it adds/remove mask to/from layer.
Copy link to clipboard
Copied
Well, finally, send keys will be my way to go, which of course is not the most beautiful one.
Copy link to clipboard
Copied
Can you share a code how you're going to send keys?
Copy link to clipboard
Copied
With a VBS file:
set WshShell = WScript.CreateObject ("WScript.Shell")
WScript.Sleep 300
WshShell.SendKeys "{DOWN}"
WScript.Sleep 10
WshShell.SendKeys "{ENTER}"
WScript.Quit
Then just execute the VBS file via a jsx file.
Copy link to clipboard
Copied
Works in cs6 and cc2018 on win7.
Sometimes it works unstably.
set_layers_thumbs(0) // 0-none,1-sm,2-med,3-large
alert("Done!")
////////////////////////////////////////////////////////////////////////////////////////////
function set_layers_thumbs(size)
{
while (ScriptUI.environment.keyboardState.keyName ||
ScriptUI.environment.keyboardState.ctrlKey ||
ScriptUI.environment.keyboardState.altKey ||
ScriptUI.environment.keyboardState.shiftKey)
{ refresh(); }
var s = "var WshShell = WScript.CreateObject('WScript.Shell');for(var i=0;i<1000;i++)if(WshShell.AppActivate('Layers Panel Options')){WshShell.SendKeys('{DOWN}');"
if (size >= 1) s += "WshShell.SendKeys('{DOWN}');";
if (size >= 2) s += "WshShell.SendKeys('{DOWN}');";
if (size >= 3) s += "WshShell.SendKeys('{DOWN}');";
s += "WshShell.SendKeys (' ');WshShell.SendKeys('{TAB}{TAB}{TAB}{TAB}{TAB}');WshShell.SendKeys (' ');break;}else WScript.Sleep(50);WshShell=null;";
var f = new File(Folder.temp.fsName + "/" + "tmp.js");
f.open("w");
f.write(s);
f.close("w");
f.execute();
runMenuItem(stringIDToTypeID("layersPaletteOptions"))
f.remove();
f = null;
}
Copy link to clipboard
Copied
You can use also '{SPACE}{ENTER}' instead of '{TAB}{TAB}{TAB}{TAB}{TAB} '​ in CS 2018, while in CS6 just '{ENTER}'.
Copy link to clipboard
Copied
All this nonsense crazy))
Copy link to clipboard
Copied
In fact the SListener doesn't records nothing when I change the thumbnail size, so I guess I have had the code to open the Layer Panel options from elsewhere, probably from the configurator.
Copy link to clipboard
Copied
Have you ever tried code I wrote for you, you never replied anything for that: Re: How to get an annotation's position ?
Copy link to clipboard
Copied
In answer to
Kukurykus a écrit
Have you ever tried code I wrote for you, you never replied anything for that: Re: How to get an annotation's position ?
Sorry for the late reply...Now it's done. I just have to learn how to use properly the forum.
Thanks again to all for sharing your knowledges.
Copy link to clipboard
Copied
How it answers to Evergreen question if he already found it himself, SL doesn't record that operation that could be used?