Copy link to clipboard
Copied
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!
app.displayDialogs = DialogModes.NO;
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
*/
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thanks for your reply. I've been already looking into this source. Just wonder why if I go into File -> Scripts -> Load Files into Stack... it shows me no further dialogs except choosing files (same way if `loadLayersFromScript` variable is not set in script), but `loadLayers.intoStack` from the same script `Load Files into Stack.jsx` does. Still looking for solution.
Copy link to clipboard
Copied
Stephen posted a link to SuperMerlin function the solution you should use in your script. You want to load some list of files into a stack and use Adobe Load File into a stack without having to use its dialog. That means you want to pass your file list to that script and have the script bypass displaying it dialog to use the file list you passes instead. The problem is the script is not designed to as a plug-in is not designed to process anything passed. You can not call of execute the script passing anything. SuperMerlins function incorporates the Load File into Stack script into itself and it uses a function in the incorporated script that will load a list of file into a stack. Therefor there needs to be a file list. SuperMerlin function would not know what files you want to load into a stack. So your script would need to create your list files and pass the file list to SuperMerlin function which you add to you script and use. Your pass you array of file objects. I have not used his function but I know SuperMerlin is just that Super
stackFiles(yourFilelist);
Copy link to clipboard
Copied
Sure, I've seen these topics. Some copy-paste of the first one actually you can see in my example. Thanks anyway!
Copy link to clipboard
Copied
Well, now I'm confused. In the `ImageStackCreator` class in the `loadStackLayers` method in the line `app.preferences.rulerUnits = Units.PIXELS;` the Preferences->Units dialog is shown, and I don't understand why. It is in `\Presets\Scripts\Stack Scripts Only\CreateImageStack.jsx` file in
Copy link to clipboard
Copied
Does thi help any?
var inputFolder = Folder.selectDialog("Select your PNG files folder");
var fileList = inputFolder.getFiles("*.png");
if (fileList!="") stackFiles(fileList);
//////////////////////////////////////////////
function stackFiles(sFiles){
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(sFiles);
};
Copy link to clipboard
Copied
Thanks for your answer! But this is actually the same code as mine.
I tried PNG and PSD files also with no success.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
I'm using English version too, it is 20.0.1 on Windows 10 OS.
Copy link to clipboard
Copied
app.displayDialogs = DialogModes.NO;
Copy link to clipboard
Copied
That helped, thanks!
Copy link to clipboard
Copied
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.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more