Hey everyone.
Can you please tell me if there is a way to know if certain panels are opened? And open/close them with script?
For example, I want a script that
a) opens Brush and Layer panels if both of them are closed
and
b) closes them if they're opened together OR only one of them is opened.
Thanks,
Sergey
Hide/open UI windows with JS
Hide/open UI windows with JS
One can determine if a Photoshop Panel is visible.
Code: Select all// check for panels;
// based on code by michael l hale;
// 2013, use it at your own risk;
#target photoshop
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var applicationDesc = executeActionGet(ref);
var panelList = applicationDesc.getList(stringIDToTypeID('panelList'));
for (var m = 0; m < panelList.count; m++) {
var thisPanelDesc = panelList.getObjectValue(m);
if (thisPanelDesc.getString(stringIDToTypeID("name")) == "Layers") {
alert ("the panel "+thisPanelDesc.getString(stringIDToTypeID("name"))+" being visible is\n"+
thisPanelDesc.getBoolean(stringIDToTypeID("visible")))
};
if (thisPanelDesc.getString(stringIDToTypeID("name")) == "Brush") {
alert ("the panel "+thisPanelDesc.getString(stringIDToTypeID("name"))+" being visible is\n"+
thisPanelDesc.getBoolean(stringIDToTypeID("visible")))
};
};
Code: Select all// check for panels;
// based on code by michael l hale;
// 2013, use it at your own risk;
#target photoshop
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var applicationDesc = executeActionGet(ref);
var panelList = applicationDesc.getList(stringIDToTypeID('panelList'));
for (var m = 0; m < panelList.count; m++) {
var thisPanelDesc = panelList.getObjectValue(m);
if (thisPanelDesc.getString(stringIDToTypeID("name")) == "Layers") {
alert ("the panel "+thisPanelDesc.getString(stringIDToTypeID("name"))+" being visible is\n"+
thisPanelDesc.getBoolean(stringIDToTypeID("visible")))
};
if (thisPanelDesc.getString(stringIDToTypeID("name")) == "Brush") {
alert ("the panel "+thisPanelDesc.getString(stringIDToTypeID("name"))+" being visible is\n"+
thisPanelDesc.getBoolean(stringIDToTypeID("visible")))
};
};
Hide/open UI windows with JS
Thanks pfaffenbichler!
Are those booleans read only? I can't figure out a way to turn them true or false
Are those booleans read only? I can't figure out a way to turn them true or false
Hide/open UI windows with JS
Are you familiar with Action Manager code at all yet (as opposed to Document Object Model code)?
Hide/open UI windows with JS
Unfortunately no, I'm not a coder at all and I understand only the simplest things.
I realiz that probably I need to use 'putReference' somehow somewhere, but I have no idea how and where, a word of help is much appreciated!
I realiz that probably I need to use 'putReference' somehow somewhere, but I have no idea how and where, a word of help is much appreciated!
Hide/open UI windows with JS
One »word« will likely not suffice.
Anyway, I used xbytor’s »ActionFileToJavascript.jsx« to get the code for an Action that toggles the Layers Panel (created via »Insert Menu Item«).
Code: Select all// thanks to xbytor;
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(charIDToTypeID('Mn '), charIDToTypeID('MnIt'), charIDToTypeID('Tgly'));
desc1.putReference(stringIDToTypeID('null'), ref1);
executeAction(charIDToTypeID('slct'), desc1, DialogModes.NO);
Unfortunately this seems to affect all Panels that are docked together.
Anyway, I used xbytor’s »ActionFileToJavascript.jsx« to get the code for an Action that toggles the Layers Panel (created via »Insert Menu Item«).
Code: Select all// thanks to xbytor;
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(charIDToTypeID('Mn '), charIDToTypeID('MnIt'), charIDToTypeID('Tgly'));
desc1.putReference(stringIDToTypeID('null'), ref1);
executeAction(charIDToTypeID('slct'), desc1, DialogModes.NO);
Unfortunately this seems to affect all Panels that are docked together.
Hide/open UI windows with JS
Interesting: this hides and unhides Layers panel, Brush stays intact. I can't understand how this works, and since I make this script for myself I think it'll be easier to make actions that hide/show panels and fire them depending of code you posted above. Ugly, but easy to do. Thanks again, pfaffenbichler!
Hide/open UI windows with JS
That code was only for the Layers Panel, for the Brush Panel it would be
Code: Select all// thanks to xbytor;
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(charIDToTypeID('Mn '), charIDToTypeID('MnIt'), charIDToTypeID('TglB'));
desc1.putReference(stringIDToTypeID('null'), ref1);
executeAction(charIDToTypeID('slct'), desc1, DialogModes.NO);
Code: Select all// thanks to xbytor;
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(charIDToTypeID('Mn '), charIDToTypeID('MnIt'), charIDToTypeID('TglB'));
desc1.putReference(stringIDToTypeID('null'), ref1);
executeAction(charIDToTypeID('slct'), desc1, DialogModes.NO);
Hide/open UI windows with JS
Ah, fair enough, the only difference is that Tgly / TglB thing. MANY THANKS! Now everything works without actions
And thanks for pointing on xbytor's ActionFileToJavascript.jsx , amazing thing!
And thanks for pointing on xbytor's ActionFileToJavascript.jsx , amazing thing!
Hide/open UI windows with JS
Maybe it’s a little consolation: I can not claim that to fully comprehend Action Manager code, either.
But on the basis of the work of and code provided by xbytor, Mike Hale, Paul Riggott, … one can utilize it even without fully understanding it, I guess.
But on the basis of the work of and code provided by xbytor, Mike Hale, Paul Riggott, … one can utilize it even without fully understanding it, I guess.