Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Running jsx files from another jsx file

Explorer ,
Nov 30, 2021 Nov 30, 2021

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. 🙂

TOPICS
Actions and scripting
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 3 Correct answers

Community Expert , Nov 30, 2021 Nov 30, 2021

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/

Translate
Community Expert , Nov 30, 2021 Nov 30, 2021
Translate
LEGEND , Nov 30, 2021 Nov 30, 2021
Translate
Adobe
Community Expert ,
Nov 30, 2021 Nov 30, 2021

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/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2021 Nov 30, 2021
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 30, 2021 Nov 30, 2021

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! 😄

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2021 Nov 30, 2021

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 );
}
JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 30, 2021 Nov 30, 2021

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 🙂

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 30, 2021 Nov 30, 2021

Why do you ask from one account, then continue from other (if that's you on both)? 😛

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 30, 2021 Nov 30, 2021

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 ^_^)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 30, 2021 Nov 30, 2021

@Stephen Marsh :

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 30, 2021 Nov 30, 2021
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 30, 2021 Nov 30, 2021

jefbr_0-1638284584095.pngexpand image

Good call! thanks!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 30, 2021 Nov 30, 2021

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2021 Nov 30, 2021
LATEST

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.

image.pngexpand imageimage.pngexpand image

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.

image.pngexpand image

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines