Here the complete code:
const batchPlay = require("photoshop").action.batchPlay;
// GET TOOL OPTIONS
async function getCurrentToolOptions () {
const app = require('photoshop').app;
const result = await batchPlay(
[
{
"_obj": "get",
"_target": [
{
"_property": "currentToolOptions"
},
{
"_ref": "application",
"_enum": "ordinal",
"_value": "targetEnum"
}
],
"_options": {
"dialogOptions": "dontDisplay"
}
}
],{
"synchronousExecution": false
});
return result[0].currentToolOptions;
}
// SET TOOL OPTIONS
async function setCurrentToolOptions(currenttooloptions) {
const app = require('photoshop').app;
const result = await batchPlay(
[
{
"_obj": "set",
"_target": [
{
"_ref": "paintbrushTool"
}
],
"to": currenttooloptions
}
],{
"synchronousExecution": false
});
}
async function currentlayer() {
let cto = await getCurrentToolOptions();
cto.$StmS = true;
cto.$StmB = flase;
await setCurrentToolOptions(cto);
}
await require("photoshop").core.executeAsModal(currentlayer);