Skip to main content
Naoki-Hada
Known Participant
July 6, 2021
Question

How to call "Fit to Screen" in UXP JavaScript?

  • July 6, 2021
  • 2 replies
  • 1933 views

Is there any way to use Zoom Fit to Screen (same as Ctrl+0) in UXP scripting?

 

In CEP/ExtendScript, we can use as following.

app.runMenuItem(app.charIDToTypeID("FtOn"));
// Fit to Screen (same as Ctrl+0)

 

It seems not implemented simiar way on Photoshop UXP DOM as 

require('photoshop').app.runMenuItem(1182027630);

 

Result:

 

From UXP Alchemist plugin's ScriptListner is showing:

{
  "_obj": "invokeCommand",
  "commandID": 1192,
  "kcanDispatchWhileModal": true,
  "_isCommand": false
}

 

From batchPlay(), above seems not runnable (this part is not quite sure).

    var result = require('photoshop').action.batchPlay([
        {
            "_obj": "invokeCommand",
            "commandID": 1192,
            "kcanDispatchWhileModal": true,
            "_isCommand": false
        }
    ], {synchronousExecution: true});

 

Result:

 

I'm not quite sure if above is proper usage of batchPlay() as well.

But is there any way to use Zoom Fit to Screen (same as Ctrl+0) in UXP scripting?

 

Thank you,

Naoki

This topic has been closed for replies.

2 replies

Geppetto Luis
Legend
July 7, 2021

That code you put ("invokeCommand")
and photoshop junk
ScriptingListener does not record fit to screen
you should do it by action

try this little code if it works

 

if (documents.length!=0) {runMenuItem(app.charIDToTypeID("FtOn"));}

Naoki-Hada
Known Participant
July 7, 2021

Hi @Geppetto Luis 

 

Thank you very much for your reply.

I know the limitation, that's why I'm asking this question.

Your code is ExtendScript and about same as my 4th line of question.

It does not work on UXP JavaScript, so I'm asking this question.

If you know working UXP code, please let me know.

 

I'm converting working CEP/ExtendScript code to UXP plugin.

This part is one of the blocker.

 

Ref. about Listner on UXP

Adobe UXP: Things you need to know! #6 BatchPlay (part 1): the ActionManager roots

 

Thank you,

Naoki

 

Kukurykus
Legend
July 6, 2021
Naoki-Hada
Known Participant
July 7, 2021

Hi @Kukurykus 

 

Thank you very much for reply.

 

But your series of links does not make any sense.

If you know the answer of my question, please post here.

 

Thank you,

Naoki

 

Kukurykus
Legend
July 7, 2021

At end of those links path you find dedicated UXP forum 😉