I am here because I did not find solution.


  • I have 4 artboards.
  • I need a script (or action) to "fit artboard on screen" or zoom in specific artboard. (NOT fit layer on screen)
  • There is a option in top menu panel/View/Fit artboard on screen. It works well when I use it with mouse click.


  1. When I try to record the Action:
    • Click on use Insert Menu Item: Fit artboard on screen, press OK
    • Nothing is recorded in the action
  2. I also tried to click the menu item at View > Fit artboard on screen, but there is still nothing added to action panel during recording.
  3. The last thing I tried was to use the Scripting listener plugin but it didn't output working code for this action.
  4. I can record View > Fit on screen as an Action, which fits all 4 artboards on screen and I need to focus/zoom in/fit on screen just one artboard.

What do i mean is on images: fit artboard on screen ... my goal

This is code for action "Fit on screen". How could it be edited for "Fit artboard on screen"? Or is there another way to get my problem solved? Thank you all!

    var desc12 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref3 = new ActionReference();
        var idMn = charIDToTypeID( "Mn  " );
        var idMnIt = charIDToTypeID( "MnIt" );
        var idFtOn = charIDToTypeID( "FtOn" );
        ref3.putEnumerated( idMn, idMnIt, idFtOn );
    desc12.putReference( idnull, ref3 );
executeAction( idslct, desc12, DialogModes.NO );

  • Char ID's are those 4 character strings in that code you posted and you can convert them to string ID's, which might give you a better idea of what they do. These are in the javascript reference PDF, but you got methods: stringIDToTypeID(), charIDToTypeID(), typeIDToCharID(), typeIDToStringID(), Unfortunately, you first need to convert to type id before you can convert to a string id: alert( typeIDToStringID(charIDToTypeID('FtOn')) );, which would return fitOnScreen. If I'm not totally wrong, that code is basically saying Action: Select From: menu > menuitem > fit on screen.
    – Joonas
    Jan 25, 2021 at 12:16
  • And you don't necessarily have to use character ID's in Action Manager code. Here's basically the same code you posted with the string id fitArtboardOnScreen.
    – Joonas
    Jan 25, 2021 at 12:28

1 Answer 1


You can record it as an Action in PS 2020 and later. Though you have to use Insert menu item... from the Action panel's flyout menu (corner menu).

I don't know the details, like if there's been bug reports or anything public, but I tested Photoshop CC 2019, CC 2020, CC 2021, and CC 2022 and CC 2019 was the only version where that didn't work, so I'm making an assumption that all versions before CC 2020 have this issue and my best guess is that it was fixed when View > Fit layer(s) on screen was added around CC 2020.

In a script (PS CC 2020+) you could use a code similar to yours, but you can also use a simpler method:

app.runMenuItem( stringIDToTypeID('fitArtboardOnScreen') );

If this is a productivity thing, and doesn't have anything to do with automation, you can also Alt + left click the artboard name in the Layers panel.

Layers Panel (PS CC 2020+):

  1. Alt + left click on the artboard layer (artboard name) → will fit the artboard on the screen
  2. Alt + left click on an empty layer or Layer 0 → will fit all artboards on the screen
  3. Alt + left click on any other layer → will fit that layer on the screen
    • The action itself works on multiple layers, but using this shortcut as the trigger you can only do one layer

You gave me a code example with Fit on screen, so I just wanted to let you know that it could also be shortened to the same runMenuItem command:

app.runMenuItem( stringIDToTypeID('fitOnScreen') );

Same goes for Fit layers on screen (PS CC 2020+)

app.runMenuItem( stringIDToTypeID('fitLayersOnScreen') );
  • Thank you. I am NOT interested in "fit layer on screen". I need "fit artboard on screen".
    – Jenna
    Oct 16, 2022 at 21:28
  • @Jenna, it's been kinda close to 2 years, but looking at my answer I don't understand where this comment is coming from? I did talk about other stuff, but I definitely prioritized fitting artboard to the screen and I don't think it's missing any information regarding it. If adding it as an action with insert menu item or the runMenuItem() method do not work, I would assume you have a version of PS where the bug is still a thing. Is you PS older than CC 2020? Even if it isn't, it's not unheard of for random things to break, especially when it comes to Actions or the JS API.
    – Joonas
    Oct 17, 2022 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.