I'm afraid it's not that simple. We can change some options directly, for example the tool mode you mentioned, as well as some (but not all*) path operations:
#target photoshop
s2t = stringIDToTypeID;
const tools = {
ellipseTool: true,
rectangleTool: true,
triangleTool: true,
polygonTool: true,
lineTool: true,
customShapeTool: true
},
geometryToolMode = ['path', 'shape', 'fill'],
shapeOperation = ['add', 'subtract', 'intersect'];
if (tools[currentTool]) {
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('tool'));
r.putEnumerated(s2t('application'), s2t('ordinal'), s2t('targetEnum'));
var cto = executeActionGet(r).getObjectValue(s2t('currentToolOptions'));
cto.putEnumerated(s2t('geometryToolMode'), s2t('geometryToolMode'), s2t(geometryToolMode[0])); // values from geometryToolMode array
cto.putEnumerated(s2t('shapeOperation'), s2t('shapeOperation'), s2t(shapeOperation[2])); // values from shapeOperation array
(r = new ActionReference()).putClass(s2t(currentTool));
(d1 = new ActionDescriptor()).putReference(s2t('target'), r);
d1.putObject(s2t('to'), s2t('target'), cto);
executeAction(s2t('set'), d1, DialogModes.NO);
}
Further, each of the tool modes has its own settings, for example path (with rectangleTool selected)
{
"_obj": "currentToolOptions",
"cornerRadiusUnit": 0,
"geometryToolMode": {
"_enum": "geometryToolMode",
"_value": "path"
},
"proportionalHeight": 1,
"proportionalWidth": 1,
"radii": {
"_obj": "radii",
"bottomLeft": {
"_unit": "pixelsUnit",
"_value": 40
},
"bottomRight": {
"_unit": "pixelsUnit",
"_value": 40
},
"topLeft": {
"_unit": "pixelsUnit",
"_value": 40
},
"topRight": {
"_unit": "pixelsUnit",
"_value": 40
},
"unitValueQuadVersion": 1
},
"radius": 0,
"rectangleRadiiLinked": true,
"shapeOperation": {
"_enum": "shapeOperation",
"_value": "interfaceIconFrameDimmed"
},
"version": 2
}
shape (with rectangleTool selected)
{
"_obj": "currentToolOptions",
"cornerRadiusUnit": 0,
"geometryToolMode": {
"_enum": "geometryToolMode",
"_value": "shape"
},
"makeShapeLayers": true,
"proportionalHeight": 1,
"proportionalWidth": 1,
"radii": {
"_obj": "radii",
"bottomLeft": {
"_unit": "pixelsUnit",
"_value": 40
},
"bottomRight": {
"_unit": "pixelsUnit",
"_value": 40
},
"topLeft": {
"_unit": "pixelsUnit",
"_value": 40
},
"topRight": {
"_unit": "pixelsUnit",
"_value": 40
},
"unitValueQuadVersion": 1
},
"radius": 0,
"rectangleRadiiLinked": true,
"shapeStyle": {
"_obj": "shapeStyle",
"fillContents": {
"_obj": "solidColorLayer",
"color": {
"_obj": "RGBColor",
"blue": 0.0038910505827516317,
"grain": 0.0038910505827516317,
"red": 255
}
},
"strokeStyle": {
"_obj": "strokeStyle",
"fillEnabled": true,
"strokeEnabled": false,
"strokeStyleBlendMode": {
"_enum": "blendMode",
"_value": "normal"
},
"strokeStyleContent": {
"_obj": "solidColorLayer",
"color": {
"_obj": "RGBColor",
"blue": 0,
"grain": 0,
"red": 0
}
},
"strokeStyleLineAlignment": {
"_enum": "strokeStyleLineAlignment",
"_value": "strokeStyleAlignCenter"
},
"strokeStyleLineCapType": {
"_enum": "strokeStyleLineCapType",
"_value": "strokeStyleButtCap"
},
"strokeStyleLineDashOffset": {
"_unit": "pointsUnit",
"_value": 0
},
"strokeStyleLineDashSet": [],
"strokeStyleLineJoinType": {
"_enum": "strokeStyleLineJoinType",
"_value": "strokeStyleMiterJoin"
},
"strokeStyleLineWidth": {
"_unit": "pixelsUnit",
"_value": 1
},
"strokeStyleMiterLimit": 100,
"strokeStyleOpacity": {
"_unit": "percentUnit",
"_value": 100
},
"strokeStyleResolution": 96,
"strokeStyleScaleLock": false,
"strokeStyleStrokeAdjust": false,
"strokeStyleVersion": 2
}
},
"useAlignedRendering": false,
"version": 2
}
pixels (with rectangleTool selected)
{
"_obj": "currentToolOptions",
"antiAlias": true,
"cornerRadiusUnit": 0,
"foregroundColor": {
"_obj": "HSBColorClass",
"brightness": 100,
"hue": {
"_unit": "angleUnit",
"_value": 0
},
"saturation": 100
},
"geometryToolMode": {
"_enum": "geometryToolMode",
"_value": "fill"
},
"mode": {
"_enum": "blendMode",
"_value": "normal"
},
"opacity": 100,
"proportionalHeight": 1,
"proportionalWidth": 1,
"radii": {
"_obj": "radii",
"bottomLeft": {
"_unit": "pixelsUnit",
"_value": 40
},
"bottomRight": {
"_unit": "pixelsUnit",
"_value": 40
},
"topLeft": {
"_unit": "pixelsUnit",
"_value": 40
},
"topRight": {
"_unit": "pixelsUnit",
"_value": 40
},
"unitValueQuadVersion": 1
},
"radius": 0,
"rectangleRadiiLinked": true,
"version": 2
}
In this case, each of the tools ellipseTool, rectangleTool, triangleTool, polygonTool, lineTool, customShapeTool can have its own additional settings. As you can see, there are a huge number of possible options here, and without understanding the specific task, you can waste a huge amount of time trying to script all possible options.
The active tool parameters are stored in the application -> tool object, you can quickly view them in JSON format using the code:
#target photoshop
s2t = stringIDToTypeID;
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('tool'));
r.putEnumerated(s2t('application'), s2t('ordinal'), s2t('targetEnum'));
(d = new ActionDescriptor()).putObject(s2t('object'), s2t('object'), executeActionGet(r));
$.writeln(executeAction(s2t('convertJSONdescriptor'), d).getString(s2t('json')));
however, you cannot use JSON to quickly change the properties of an object - you need to write separate functions that change one or another parameter (approximately the same way ScriptListener does it)
* When changing the tool parameters, all shapeOperation options are unavailable, since in fact these are not path creation parameters, but separate operations for changing the pathComponents properties (each shape or path object can consist of several pathComponents, after the figure is drawn, you can assign it one or another combining mode). You can see these operations as separate executeAction() in the code generated by ScriptListener.