How to call a .jsx file from a .psjs file?

How to use a .psjs file in Photoshop to call a .jsx file, for example, if the content of the .jsx file is: alert(“Hello”);

From what I know it can’t be done But you could do it this way, In the psjs file you call an action, in the action you put the link to the .jsx file

It was possible to achieve in this way, but it does not have future potential, so I recommend to write everything in UXP.

// main.psjs

/**
  * @file Execute ExtendScript from UXP Script
  * https://forums.creativeclouddeveloper.com/t/how-to-call-a-jsx-file-from-a-psjs-file/
  * https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-call-a-jsx-file-from-a-psjs-file/td-p/15193966
  * @version 1.0.0
  * @author sttk3.com
*/

const { localFileSystem } = require('uxp').storage ;
const { app, core, action } = require('photoshop') ;

const jsxFile = await localFileSystem.getEntryWithUrl('/Users/username/Desktop/alert.jsx') ;
const token = await localFileSystem.createSessionToken(jsxFile) ;

try {
  await core.executeAsModal(async () =>
    {
      await action.batchPlay(
        [
          {
            _obj: 'AdobeScriptAutomation Scripts',
            javaScript: {
              _kind: 'local',
              _path: token
            },
          }
        ], 
        
        {}
      ) ;
    }, 
    
    {
      commandName: 'ExtendScript', 
      interactive: true, 
    }
  ) ;
} catch(e) {
  await app.showAlert(e) ;
}
// alert.jsx

alert("Hello") ;
2 Likes

Thank you for your help, thank you