I found a usable script. This script successfully allows me to select the eraser tool and then set the flow and opacity. However, there is a problem with setting the eraser size and hardness. Can you help me modify it?
if (documents.length == 0) {
var d = documents.add();
} else {
var d = activeDocument;
}
// 创建两个图层以便启用背景和透明
if (d.layers.length == 1) {
d.artLayers.add();
}
// 选择橡皮擦工具
var idslct = stringIDToTypeID( "select" );
var desc226 = new ActionDescriptor();
var idnull = stringIDToTypeID( "null" );
var ref170 = new ActionReference();
var idErTl = stringIDToTypeID( "eraserTool" ); // 橡皮擦工具
ref170.putClass( idErTl );
desc226.putReference( idnull, ref170 );
executeAction( idslct, desc226, DialogModes.NO );
// 设置透明度为50%、流量为50%、画笔大小为1400、硬度为100%
var idset = stringIDToTypeID( "set" );
var desc226 = new ActionDescriptor();
var idnull = stringIDToTypeID( "null" );
var ref170 = new ActionReference();
var idErTl = stringIDToTypeID( "eraserTool" ); // 橡皮擦工具
ref170.putClass( idErTl );
desc226.putReference( idnull, ref170 );
var id12 = stringIDToTypeID( "to" );
var desc5 = new ActionDescriptor();
var id13 = stringIDToTypeID( "opacity" );
var id14 = stringIDToTypeID( "percentUnit" );
desc5.putUnitDouble( id13, id14, 50 ); // 设置透明度为50%
var id19 = stringIDToTypeID( "flow" );
desc5.putUnitDouble( id19, id14, 50 ); // 设置流量为50%
var id20 = stringIDToTypeID( "diameter" );
desc5.putUnitDouble( id20, id14, 1400 ); // 设置画笔大小为1400
var id21 = stringIDToTypeID( "hardness" );
desc5.putUnitDouble( id21, id14, 100 ); // 设置硬度为100%
desc226.putObject( id12, idnull, desc5 );
executeAction( idset, desc226, DialogModes.NO );
'DONE';