Help With View Fit On Screen BatchPlay

I am trying to figure out how to get an image to Fit on Screen In Photoshop similar to using the Menu Item View -> Fit On Screen

I have tried Alchemist but I dont think it records any of the Zoom options.

Ian

Here is the JSX function to do that. It is on my to do list to try to figure out how to put this into a UXP batchPlay descriptor but I haven’t attempted that yet. Based on what I read in the decriptors documentation, I think the 4 letter designators need to be switched to '$Mn ', ‘$MnIt’ and ‘$FtOn’. I’m guessing there is someway to mash this into a batchPlay descriptor.

function fitOnScreen() {	
cTID = function(s) { return app.charIDToTypeID(s); };
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( cTID( 'Mn  ' ), cTID( 'MnIt' ), cTID( 'FtOn' ) );
desc.putReference( cTID( 'null' ), ref );
executeAction( cTID( 'slct' ), desc, DialogModes.NO );
}

yup, it’s
{
_obj: ‘select’,
_target: [
{
_ref: '$Mn ',
_enum: ‘$MnIt’,
_value: ‘fitOnScreen’,
},
]
}

1 Like

Thanks! That helps a lot.

Thanks @simonhenke

I managed to get the code from Script Listener but could not figure out how to put it into BatchPlay.

I understand @Jarda has a tool to convert the old script listener code into batchPlay but cannot think of its name. Have you tried it

Looking at your code Simon, I presume we could also use the same logic for the Zoom In Menu option which I think would be something like this.

async function ZoomIn() {
   const batchPlay = require("photoshop").action.batchPlay;
   const result = await batchPlay(
  [
     {
        _obj: "select",
        _target: [
           {
              _ref: "$Mn",
              _enum: "$MnIt",
              _value: "zoomIn",
           },
        ]
     }
  ], {
  "synchronousExecution": false,
  "modalBehavior": "fail"
   });
}

Haven’t tried that one out yet. The Descriptor wasn’t really complex so you can just assemble it by looking at the AM code.

Sure, if “zoomIn” is a command available through the menu it should work - haven’t you tried it?

Just tried ZoomIn and ZoomOut and they both work fine based on your code example

Is there a link somewhere to the script listener code converter? I would be interested to try it. I have quite a bit of script listener code I would like to convert.

I think this is the one @Jarda is working on

Have you been able to figure out how to use it? I tried loading the plugin but it just opens an empty UI. Maybe it just records a log file somewhere?

This does not have UI yet. This is just a source code for now. Not a plugin. The plugin is only for me to test it and will be removed. This was intended to be a Node Module.

Thanks for the clarification.