Possible work-around is creating a new Brush Preset to determine the name of the selected Brush Preset.
I included a check for the Brush Tool being selected, if other Tools are involved another approach might be better.
// reset brush to selected brush preset;
// 2026, use it at your own risk;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var applicationDesc = executeActionGet(ref);
var theTool = typeIDToStringID(applicationDesc.getEnumerationType(stringIDToTypeID("tool")));
// if brush tool;
if (theTool == "paintbrushTool") {
// get list of brushes;
var theBrushes = brushName(0);
// create new brush;
var aNewName = "deleteThis"+String(Math.random());
createNewBrush (aNewName);
// get new list of brushes and check;
var theNewBrushes = brushName(0);
for (var m = 0; m < theNewBrushes.length; m++) {
if (theNewBrushes[m] == aNewName) {theBrushName = theNewBrushes[m-1]};
};
// remove brush;
deleteSelectedBrush ();
// check for multiples in list;
var theMatches = new Array;
for (var m = 0; m < theBrushes.length; m++) {
if (theBrushes[m] == theBrushName) {theMatches.push(m)}
};
switch (theMatches.length) {
case 1:
selectBrush (theBrushName);
break;
case 0:
alert ("brush missing");
break;
default:
alert ("please clean up your brushes panel");
break
};
};
////// //////
function createNewBrush (aName) {
// =======================================================
var idmake = stringIDToTypeID( "make" );
var desc10 = new ActionDescriptor();
var idnull = stringIDToTypeID( "null" );
var ref3 = new ActionReference();
var idbrush = stringIDToTypeID( "brush" );
ref3.putClass( idbrush );
desc10.putReference( idnull, ref3 );
var idname = stringIDToTypeID( "name" );
desc10.putString( idname, aName );
var idusing = stringIDToTypeID( "using" );
var ref4 = new ActionReference();
var idproperty = stringIDToTypeID( "property" );
var idcurrentToolOptions = stringIDToTypeID( "currentToolOptions" );
ref4.putProperty( idproperty, idcurrentToolOptions );
var idapplication = stringIDToTypeID( "application" );
var idordinal = stringIDToTypeID( "ordinal" );
var idtargetEnum = stringIDToTypeID( "targetEnum" );
ref4.putEnumerated( idapplication, idordinal, idtargetEnum );
desc10.putReference( idusing, ref4 );
var idcaptureSize = stringIDToTypeID( "captureSize" );
desc10.putBoolean( idcaptureSize, false );
var idcaptureTool = stringIDToTypeID( "captureTool" );
desc10.putBoolean( idcaptureTool, false );
executeAction( idmake, desc10, DialogModes.NO );
};
////// delete brush //////
function deleteSelectedBrush () {
try {
var iddelete = stringIDToTypeID( "delete" );
var desc223 = new ActionDescriptor();
var idnull = stringIDToTypeID( "null" );
var ref3 = new ActionReference();
ref3.putEnumerated( stringIDToTypeID( "brush" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ) );
desc223.putReference( idnull, ref3 );
executeAction( iddelete, desc223, DialogModes.NO );
} catch (e) {alert ("problem")}
};
////// delete brush //////
function deleteBrushes (theName) {
try {
var iddelete = stringIDToTypeID( "delete" );
var desc223 = new ActionDescriptor();
var idnull = stringIDToTypeID( "null" );
var ref3 = new ActionReference();
ref3.putName( stringIDToTypeID( "brush" ), String(theName) );
desc223.putReference( idnull, ref3 );
executeAction( iddelete, desc223, DialogModes.NO );
} catch (e) {alert ("problem")}
};
////// selectBrush //////
function selectBrush (theBrushName) {
var desc4 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName( stringIDToTypeID( "brush" ), theBrushName );
desc4.putReference( stringIDToTypeID( "null" ), ref1 );
executeAction( stringIDToTypeID( "select" ), desc4, DialogModes.NO );
};
//////
function brushName(x) {
var presetNames = [];
var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
var desc = executeActionGet(ref);
var List = desc.getList(stringIDToTypeID('presetManager'));
var list = List.getObjectValue(x).getList(charIDToTypeID('Nm '));
for (var i = 0; i < list.count; i++) {
presetNames.push(list.getString(i));
};
return presetNames;
};