Skip to main content
Participating Frequently
April 2, 2020
Answered

Load Files into Stack in script without dialogs quietly

  • April 2, 2020
  • 7 replies
  • 3983 views

Hi!

 

I'm trying to use `Load Files into Stack` in my script, but it opens dialogs on every `loadLayers.intoStack` call.

 

It asks about units preferences, new layer name, renaming layer, duplicating layer, and renaming layer again, and units preferences once more. Every time I have to click `ok`.

 

Here is example of my code:

 

function main() {
    var defaultFolder = new Folder("myFolderPath");

    var inputFolder = defaultFolder.selectDlg("Select input folder", "", false);

    if (inputFolder == null) return;

    var filesList = inputFolder.getFiles("*.jpg");

    var loadLayersFromScript = true; 

    var SCRIPTS_FOLDER =  decodeURI(app.path + '/' + localize('$$$/ScriptingSupport/InstalledScripts=Presets/Scripts'));

    $.evalFile( new File(SCRIPTS_FOLDER +  '/Load Files into Stack.jsx'));

    loadLayers.intoStack(filesList.slice(0,3), true);
}

main();

 

 

I’m looking for a way to suppress those dialogs, is there such one?

 

Thanks!

This topic has been closed for replies.
Correct answer r-bin

app.displayDialogs = DialogModes.NO;

7 replies

Participating Frequently
April 30, 2020

One solution is to put the script under `\Presets\Scripts` directory and to run in from File -> Scripts menu. It makes it to run flawlessly without dialogues popping out around.

r-binCorrect answer
Legend
April 30, 2020

app.displayDialogs = DialogModes.NO;

Participating Frequently
April 30, 2020

That helped, thanks!

Stephen Marsh
Community Expert
Community Expert
April 3, 2020

I don't have any dialogs popping up in my tests of your original code, or for example in the previous code posted by JJMack.

 

I am using an English version installation (CC 2019, Mac OS) – perhaps this is a localisation issue?

Participating Frequently
April 30, 2020

I'm using English version too, it is 20.0.1 on Windows 10 OS.

JJMack
Community Expert
Community Expert
April 3, 2020

So the solution seems to be: Incorporate the Photoshop script Load File into stack.jsx into you own script and use a function in the incorporated  script passing it a file list your script need to create first.  It looks like the Load File into stack script Incorporated all the stack mode scripts into its process

var g_StackScriptFolderPath = app.path + "/"+ localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts") + "/"
										+ localize("$$$/private/LoadStack/StackScriptOnly=Stack Scripts Only/");

$.evalFile(g_StackScriptFolderPath + "LatteUI.jsx");

$.evalFile(g_StackScriptFolderPath + "StackSupport.jsx");

$.evalFile(g_StackScriptFolderPath + "CreateImageStack.jsx");

 

Its great to have users like SuperMerlin that know JavaScrpt and Photoshop scripts participate here. 

 

You all most always get solution faster by searching before asking question because you are usually not the first person having your problem.  Sill question help many besides the user asking for help. So I like seeing thread like this one.

 

Even reading Load Files into Stack code I would not know how to use it in my own script without  users like SuperMerlin... Thanks wizard

JJMack
JJMack
Community Expert
Community Expert
April 3, 2020

Load File into a stack may not be a Photoshop Plug-in. If which case there is no code in the script that will bypass opening its dialog. 

 

Looking at its HARVEST_EXCEPTION_ZSTRING there are no parameter in it. I just see its UUID. There is no way to pass what file you want to load into a stack.  So it not a Photoshop Plug-in.

 

 

 

// (c) Copyright 2006.  Adobe Systems, Incorporated.  All rights reserved.

/*
@@@BUILDINFO@@@ Load Files into Stack.jsx 1.0.0.2
*/

//
// Load Files into Stack.jsx - does just that.
//

/*

// BEGIN__HARVEST_EXCEPTION_ZSTRING

<javascriptresource>
<name>$$$/JavaScripts/LoadFilesintoStack/Menu=Load Files into Stack...</name>
<eventid>6F17BFA7-EFC8-40EA-B850-7B95ED8EA713</eventid>
</javascriptresource>

// END__HARVEST_EXCEPTION_ZSTRING

*/

 

 

Photoshop Plug-in Scripts like Fit Image have paramaters that can be passed in its HARVEST_EXCEPTION_ZSTRING. 

 

 

/* Special properties for a JavaScript to enable it to behave like an automation plug-in, the variable name must be exactly
   as the following example and the variables must be defined in the top 1000 characters of the file

// BEGIN__HARVEST_EXCEPTION_ZSTRING
<javascriptresource>
<name>$$$/JavaScripts/FitImage/Name=Fit Image...</name>
<menu>automate</menu>
<enableinfo>true</enableinfo>
<eventid>3caa3434-cb67-11d1-bc43-0060b0a13dc4</eventid>
<terminology><![CDATA[<< /Version 1
                         /Events <<
                          /3caa3434-cb67-11d1-bc43-0060b0a13dc4 [($$$/AdobePlugin/FitImage/Name=Fit Image) /imageReference <<
	                       /width [($$$/AdobePlugin/FitImage/Width=width) /pixelsUnit]
	                       /height [($$$/AdobePlugin/FitImage/Height=height) /pixelsUnit]
	                       /limit [($$$/AdobePlugin/FitImage/limit=Don't Enlarge) /boolean]
                          >>]
                         >>
                      >> ]]></terminology>
</javascriptresource>
// END__HARVEST_EXCEPTION_ZSTRING
*/

 

 

JJMack
Stephen Marsh
Community Expert
Community Expert
April 3, 2020

I just tried your script as I was going to suggest including app.displayDialogs = DialogModes.NO; – but there was no need as apart from the folder selection, no other dialogs came up at all (I was using PSD files as the source, that was the only change I made to your script, apart from removing the fileList.slice as I wanted to test the entire folder content, not limit it to 3). I was testing on a Mac with CC 2019.

Stephen Marsh
Community Expert
Community Expert
April 3, 2020

I'd adjust another script, such as:

 

http://morris-photographics.com/photoshop/scripts/import-folder.html

 

Changing the Folder.selectDialog for a different variable or hard-coded input path etc.