Changing Magic Wand tool options with code

Is there a way to check/uncheck “Sample all layers” option with code?
Im talking about this thing here:
MagicWandOptions

I was able to read this setting but I cannot set them. Options look like this:

“Sample all layers” option is the “windowsSystem” here.
$WndA is “Anti-aliasing” and $WndT is tolerance.
Are just the first two options available for setting or Im missing something?

Shameless self bump

If anyone from the Adobe team is reading this and “Sample all layers” truly cannot be set please consider fixing this. It`s a very important feature to be left out like that.

How did you try to change these options?

Check this example as a guideline (it’s for paint brush):

And here’s for clone stamp:

Should be pretty much the same logic for magic wand too

1 Like

Well, I have been looking at the exact thread and tried around 100 times with no success, but today somehow I got it to work. Thanks.
Here is the code snippet:

async function getOptions() {
  console.log("getOptions called");
  storedOptions  = await getCurrentToolOptions();
  storedOptions.windowsSystem = true;
  console.log(storedOptions);
}

async function getCurrentToolOptions () {
  const result = await batchPlay(
  [
     {
        "_obj": "get",
        "_target": [
           {
              "_property": "currentToolOptions"
           },
           {
              "_ref": "application",
              "_enum": "ordinal",
              "_value": "targetEnum"
           }
        ],
        "_options": {
           "dialogOptions": "dontDisplay"
        }
     }
  ],{
     "synchronousExecution": false
  });
  return result[0].currentToolOptions;
}



async function setCurrentToolOptions() {
await executeAsModal (async () => { 
await batchPlay(
  [
     {
        "_obj": "set",
        "_target": [
           {
             "_ref": "magicWandTool"
           }
        ],
        "to": storedOptions
     }
  ],{
     "synchronousExecution": false
}