Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Loop over available tools in Photoshop

Engaged ,
Apr 04, 2024 Apr 04, 2024

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...

542
Translate
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

correct answers 1 Correct answer

Community Expert , Apr 04, 2024 Apr 04, 2024

 

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
...
Translate
Community Expert ,
Apr 04, 2024 Apr 04, 2024
Translate
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 ,
Apr 04, 2024 Apr 04, 2024

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

Translate
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 ,
Apr 04, 2024 Apr 04, 2024

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? 

Translate
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
Engaged ,
Apr 04, 2024 Apr 04, 2024

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?

Translate
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 ,
Apr 04, 2024 Apr 04, 2024

Why do you want to »access each tool«? 

What is the actual point of the exercise? 

Translate
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 ,
Apr 04, 2024 Apr 04, 2024

 

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;
};
};

 

Translate
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 ,
Apr 04, 2024 Apr 04, 2024
LATEST

Filtering for »inToolBar« »true« I get 69 Tools. 

Screenshot 2024-04-04 at 17.01.32.png

Translate
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