Copy link to clipboard
Copied
Hello
I have a bunch of scripts that I would like to call from a single "motherscript". Any idea how I could do this please?
The child scripts all look like this:
//@target photoshop;
(function() {
/*Script contents goes here*/
})();
The mother script could look something like this:
(function() {
if (searchKeyword("scriptA")){
/* load and run file a.jsx */
}
if (searchKeyword("scriptB")){
/* load and run file b.jsx */
}
if (searchKeyword("scriptC")){
/* load and run file c.jsx */
}
})();
How could I load them from motherscript.jsx?
I'm really stuck on this, any help is appreciated. 🙂
3 Correct answers
Hi! I'm not a scripter, but I would have a look at Davide's other blog entries if this one does not fit the bill: https://www.davidebarranca.com/2014/01/html-panels-tips-2-including-multiple-jsx/
https://gist.github.com/MarshySwamp/eb36460ae2813b6fc47e2d3fec48deb3
A roundabout way would be to record a script into an action, then call the action from the script:
https://gist.github.com/MarshySwamp/895140f2867fdad69efd5aedf5a70649
More here:
https://extendscript.docsforadobe.dev/extendscript-tools-features/preprocessor-directives.html
Explore related tutorials & articles
Copy link to clipboard
Copied
Hi! I'm not a scripter, but I would have a look at Davide's other blog entries if this one does not fit the bill: https://www.davidebarranca.com/2014/01/html-panels-tips-2-including-multiple-jsx/
Copy link to clipboard
Copied
https://gist.github.com/MarshySwamp/eb36460ae2813b6fc47e2d3fec48deb3
A roundabout way would be to record a script into an action, then call the action from the script:
https://gist.github.com/MarshySwamp/895140f2867fdad69efd5aedf5a70649
More here:
https://extendscript.docsforadobe.dev/extendscript-tools-features/preprocessor-directives.html
Copy link to clipboard
Copied
Seems that this is what I need:
$.evalFile("theJSXfileIWant.jsx");
Thank you both for the amazingly fast correct answers. I'm going to have so much fun with this! 😄
Copy link to clipboard
Copied
Scripts cans also be Plug-in like Adobe's plug-in script File>Automate>Fit Image.jsx... If you look at the code in Adobe's Image Processor.. Script you can see how the Script Pass the Action manage message to the Plug-in script to have the document resized to fit within the width and height.
// use the fit image automation plug-in to do this work for me
function FitImage( inWidth, inHeight ) {
if ( inWidth == undefined || inHeight == undefined ) {
alert( strWidthAndHeight );
return;
}
var desc = new ActionDescriptor();
var unitPixels = charIDToTypeID( '#Pxl' );
desc.putUnitDouble( charIDToTypeID( 'Wdth' ), unitPixels, inWidth );
desc.putUnitDouble( charIDToTypeID( 'Hght' ), unitPixels, inHeight );
var runtimeEventID = stringIDToTypeID( "3caa3434-cb67-11d1-bc43-0060b0a13dc4" );
executeAction( runtimeEventID, desc, DialogModes.NO );
}
Copy link to clipboard
Copied
I'm so sorry JJMack, I really can't figure out what you mean to say.
this part: "... the Script Pass the Action manage message to the Plug-in script ... " is a mistery to me.
Would you or anybody else be able to clarify what is meant here? It sounds interesting! Thx 🙂
Copy link to clipboard
Copied
Why do you ask from one account, then continue from other (if that's you on both)? 😛
Copy link to clipboard
Copied
Becaaaaause.... I messed up one time and made a second account and didn't realize. At times (and I still haven't figured out why) my browser (chrome) switches from one chrome user to another chrome user and i'm """suddendly""" bumped from one account to another.
So... a bit of pebkac, a bit of not having an idea on how to port my account to one address and a bit of not having a proper personal policy for making sure I can keep this account forever. (I like my correct answers and likes ^_^)
Copy link to clipboard
Copied
on the extendscript docs "#script name" is mentioned. Do you happen to know what that can be used for?
I can find that it's used as the menu item name in the File>script> submenu, but is it used elsewhere as well?
Would it be a good idea to add a custom name to every jsx file or is that overkill? Thanks a bunch!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Good call! thanks!!
Copy link to clipboard
Copied
Most programming languages have lots of includes in the file headers. This is an easy way to reference one bit of code from something else and supported in Extendscript. You can also read and write preferences to a common custom space which makes things much easier.
Copy link to clipboard
Copied
Scripts are often interactive they display a dialog or prompt the user for information, settings, select folders, files, create file lists, before execution. Some of these script Support being recorded into actions and they will record the information users Passed in their dialog into the Action step being recorded. When the recorded action is played the Action Manager will Pass the recorded dialog information to the Script and the script will bypass displaying its dialog and use the pass information. The script is fully automatic this way no user interaction is required. So the Action can be batched. This type of Script Work like Photoshop Plug-in that you install into Photoshop's Plug-in folder. However they are installed in Photoshop Script folder and these scripts install themselves into Photoshop as a menu Item usually in Photoshop's menu File>Automate>... . Photoshop Plug-in scripts like: Fit mage.jsx, ContactSheetII.jsx, Lens Correct.jsx, Merge To HDR.jsx, Photomerge.jsx and Download like X's Image Processor Pro.jsx, My AspectRatioSelection.jsx and LongSidePrintLength.jsx. A script can use these Scripts interactivity where the script will display the its dialog for user interaction so users can pass parameters to the Script. Or have the Script be automated by Pass the Plug-in script the Parameters for the scripts dialog so the script will work without requiring user interaction.
The Code I posted From Image Processor showed how to Pass the Parammeters to the Script like the Action Manager does. Plug-in scripts have headers that describe their dialog's Paramaters.

