How do I enter data into a modal produced through batchPlay?

Hi! I’m currently working on a small UXP plugin that uses batchPlay to export artboards. Using Alchemist I found out that I can trigger the “Artboards to Files…” command by doing this:

const commands = {
    _obj: "AdobeScriptAutomation Scripts",
    javaScriptName: "Artboards to Files...",
    javaScriptMessage: "undefined",
    _isCommand: false,
    _options: {
      dialogOptions: "dontDisplay"
action.batchPlay(command, {});

However, this just opens the export window.

Is there a way I can supply data and run this in the background? Thanks!

1 Like

For these dialog windows, I usually fill them in the way I want and click the button for doing what they do. Usually “OK” but it looks like “Run” in this case. I capture the event with the “Listener” in Alchemist. This provides the batchPlay code Then I set the batchPlay options to:

dialogOptions: "display"

This usually opens the dialog window with the fields prefilled with whatever was captured by Listener and transferred to batchPlay.

Haven’t tried this with “Artboards To Files” so don’t know if it works for this, however, this method even lets you insert variables for things in the batchPlay, so it’s proven nicely flexible in a couple of circumstances.

Gotcha. That’s what I thought was supposed to happen although I’m not seeing an event generated with my selected options after a press run.

Does this possibly have something to do with it being of type AdobeScriptAutomation Script?

AdobeScriptAutomation Script are usually Extendscript scripts. This is also the case for Artboards to Files. It’s a jsx file (you can find it in the folder Presets/Scripts) that will be called with the batchPlay you posted.
It’s not possible to provide data without modifying the script
I would strongly suggest to rewrite the JSX (Extendscript/ScriptUI) to UXP if you want to use it in an UXP plugin.


Ohhh I didn’t know about that. Thanks so much! I’ll look into this!

I haven’t looked at the code of Artboards to Files yet, but I noticed that it’s SUPER inefficient. It takes so long to execute and does some weird steps in between, where I immediately thought “this could be solved in a better way”.

Since then I always just select the artboards and use Layer > Export as which is way faster. Is there anything I’m missing that Artboards to Files provides but Export as doesn’t. To me this script looks like a leftover from old times :smiley:

1 Like

Quick question, would you happen to know where this directory would be on Windows? I can’t seem to find it. Thanks!

Good point! My reason for using this is that it exports only artboards. With the Photoshop API when you load the layers from the current document there is no way to differentiate them from an artboard or a grouped layer (I may be wrong about this though. If you have an idea, then let me know!)

It should be the same path.

\Program Files\Adobe\Adobe Photoshop 2021\Presets\Scripts

1 Like

There’s a property called artboardEnabled on the Layer Descriptor

1 Like

@tomzag I don’t seem to have an Adobe Photoshop 2021 folder there, however, I did spin up a macOS VM and was able to find it where you initially said. Thanks so much for the help!

@simonhenke Interesting! I didn’t know about this. I’ll definitely look into it. Thanks so much for all of the help!

1 Like

You are probably looking in Program Files (x86) instead of Program Files.

Or you chose another install location for PS.

1 Like

Or you chose another install location for PS.

Oh wait, you’re right :sweat_smile:
I did use another install location for PS. Found it! Thanks for suggesting that! Definitely user error this time :laughing:

1 Like