Changing The Rectangle Marquee Size

I am wanting to change the Height of the Rectangle Marquee Tool.

Using Alchemist, I can Get current Height Value but I just cannot figure out how to Set a new value because thats not recorded in Alchemist.

const batchPlay = require("photoshop").action.batchPlay;

const result = await batchPlay(
[
   {
      "_obj": "get",
      "_target": [
         {
            "_property": "currentToolOptions"
         },
         {
            "_ref": "application",
            "_enum": "ordinal",
            "_value": "targetEnum"
         }
      ],
      "_options": {
         "dialogOptions": "dontDisplay"
      }
   }
],{
   "synchronousExecution": false,
   "modalBehavior": "fail"
});
const pinned = result[0].currentToolOptions.$MrqI.$FxdH;

You get the options, change what you need and then set them back with set
Check the solution of this topic - it’s almost exactly what you need

Ive read all that post with interest,

The puzzling part is the Set command as I think the layout is different to that of the Brush Opacity as I cannot seem to locate the width and height od the Marquee values.

await batchPlay(
    [
       {
          "_obj": "set",
          "_target": [
             {
               "_ref": "marqueeRectTool"
             }
          ],
          "to": //not sure 
       }
    ],{
       "synchronousExecution": false
    });
    
const batchPlay = require("photoshop").action.batchPlay;

await batchPlay(
[
   {
      "_obj": "set",
      "_target": [
         {
            "_ref": "channel",
            "_property": "selection"
         }
      ],
      "to": {
         "_obj": "rectangle",
         "top": {
            "_unit": "pixelsUnit",
            "_value": 300
         },
         "left": {
            "_unit": "pixelsUnit",
            "_value": 300
         },
         "bottom": {
            "_unit": "pixelsUnit",
            "_value": 600
         },
         "right": {
            "_unit": "pixelsUnit",
            "_value": 400
         }
      },
      "_isCommand": true,
      "_options": {
         "dialogOptions": "dontDisplay"
      }
   }
],{
   "synchronousExecution": false,
   "modalBehavior": "fail"
});

Change "_value": to what you need…

1 Like

This would be your changed result[0].currentToolOptions from the getter.
But maybe @Pierre_G solution would be even more elegant

@Pierre_G code is a nice elegant way if you want to draw a selection but I am trying to set the values in the tool bar like this

So you can approach it like this: you want to set Width and Height. BatchPlay needs the corner positions of the rectangle. Now you can work out what these are if you know the Width & Height :wink:

By selecting Fixed Size in the top menu, the rectangle will always be that size regardless of where the mouse is clicked ( which is what I want)

So if you set the fixed size to W=20 H=20 regardless of where you click on the image, you will always get a 20 x 20 rectangle selection ( which is what I want) and the only way I can see is changing those values in the Tool Bar some how

As I dont know where the mouse is going to be clicked, I dont know the other values.

Using the method from @Pierre_G I managed to get something working to my satisfaction.

Thanks