Copy link to clipboard
Copied
Is it possible to access app.tools as an array? I'm sure tools vary from PS version to version.
So loop over the array find their name and then access them by the name?
var str = "";
for (var i=0; i < tool.length; i++)
{
str += i + " " + tool[i] + "\n";
}
alert(str);
0 moveTool
1 marqueeRectTool
2 marqueeEllipTool
3 marqueeSingleRowTool
etc...
edited:
// based on code by michael l hale;
// 2024, use it at your own risk;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var applicationDesc = executeActionGet(ref);
var theToolsList = applicationDesc.getList(stringIDToTypeID("tools"));
var theList = new Array;
for (var m = 0; m < theToolsList.count; m++) {
theList.push (theToolsList.getObjectValue(m).getString(stringIDToTypeID("toolID")))
//checkDesc2 (theTo...
Copy link to clipboard
Copied
On a related point, selecting tools via AM code, not DOM:
https://www.ps-scripts.com/viewtopic.php?f=68&t=11342&p=64930&hilit=selectTool#p64930
Copy link to clipboard
Copied
I'm not aware of a property for app.tool or app.tools
There is app.currentTool
https://theiviaxx.github.io/photoshop-docs/Photoshop/Application/currentTool.html
Copy link to clipboard
Copied
What is the point here?
Are you trying to determine the Photoshop version by the available Tools or what good is the list of Tools in your workflow?
Copy link to clipboard
Copied
Everything is pointintless and nothing has meaning...
However, since in order to access each tool you need to know it's name.
It makes sense (to me at least) to get Photoshop to list them for you - just incase any commented list becomes outdated.
Does that make sense?
Copy link to clipboard
Copied
Why do you want to »access each tool«?
What is the actual point of the exercise?
Copy link to clipboard
Copied
edited:
// based on code by michael l hale;
// 2024, use it at your own risk;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var applicationDesc = executeActionGet(ref);
var theToolsList = applicationDesc.getList(stringIDToTypeID("tools"));
var theList = new Array;
for (var m = 0; m < theToolsList.count; m++) {
theList.push (theToolsList.getObjectValue(m).getString(stringIDToTypeID("toolID")))
//checkDesc2 (theToolsList.getObjectValue(m))
};
alert (theToolsList.count+" tools:\n"+theList.join("\n"));
////////////////////////////////////
////// based on code by michael l hale //////
function checkDesc2 (theDesc) {
var c = theDesc.count;
var str = '';
for(var i=0;i<c;i++){ //enumerate descriptor's keys
str = str + 'Key '+i+' = '+typeIDToStringID(theDesc.getKey(i))+': '+theDesc.getType(theDesc.getKey(i))+'\n'+getValues (theDesc, i)+'\n';
};
alert("desc\n\n"+str);
};
////// check //////
function getValues (theDesc, theNumber) {
switch (theDesc.getType(theDesc.getKey(theNumber))) {
case DescValueType.ALIASTYPE:
return theDesc.getPath(theDesc.getKey(theNumber));
break;
case DescValueType.BOOLEANTYPE:
return theDesc.getBoolean(theDesc.getKey(theNumber));
break;
case DescValueType.CLASSTYPE:
return theDesc.getClass(theDesc.getKey(theNumber));
break;
case DescValueType.DOUBLETYPE:
return theDesc.getDouble(theDesc.getKey(theNumber));
break;
case DescValueType.ENUMERATEDTYPE:
return (typeIDToStringID(theDesc.getEnumerationValue(theDesc.getKey(theNumber)))+"_"+typeIDToStringID(theDesc.getEnumerationType(theDesc.getKey(theNumber))));
break;
case DescValueType.INTEGERTYPE:
return theDesc.getInteger(theDesc.getKey(theNumber));
break;
case DescValueType.LISTTYPE:
return theDesc.getList(theDesc.getKey(theNumber));
break;
case DescValueType.OBJECTTYPE:
return (theDesc.getObjectValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getObjectType(theDesc.getKey(theNumber))));
break;
case DescValueType.RAWTYPE:
return theDesc.getReference(theDesc.getData(theNumber));
break;
case DescValueType.REFERENCETYPE:
return theDesc.getReference(theDesc.getKey(theNumber));
break;
case DescValueType.STRINGTYPE:
return theDesc.getString(theDesc.getKey(theNumber));
break;
case DescValueType.UNITDOUBLE:
return (theDesc.getUnitDoubleValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getUnitDoubleType(theDesc.getKey(theNumber))));
break;
default:
break;
};
};
Copy link to clipboard
Copied
Filtering for »inToolBar« »true« I get 69 Tools.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more