Skip to main content
Known Participant
September 26, 2019
Question

Photoshop CEP panel and user jsx path

  • September 26, 2019
  • 1 reply
  • 2195 views

I'm making a CEP panel in photoshop and i'd like to specify a folder that is not in the extension in which to run scripts.

This is the code im currently using.

 

var csInterface=new CSInterface,gExtensionId="testPanel", event=new CSEvent("com.adobe.PhotoshopPersistent","APPLICATION");


event.extensionId=gExtensionId;csInterface.dispatchEvent(event);

function onLoaded(){
var a=new CSInterface;b=a.hostEnvironment.appName;"FLPR"!=b&&loadJSX();
for(var c=["PHXS"],e=0;e<c.length;e++){var d=c[e];if(0<=b.indexOf(d)&&(d=document.getElementById("btn_"+d)))d.disabled=!1}updateThemeWithAppSkinInfo(a.hostEnvironment.appSkinInfo);
a.addEventListener(CSInterface.THEME_COLOR_CHANGED_EVENT,onAppThemeColorChanged)}

var extensionRoot=csInterface.getSystemPath(SystemPath.EXTENSION)+"/jsx/scripts/";


function loadJSX()
{
var a=new CSInterface,c=a.getSystemPath(SystemPath.EXTENSION)+"/jsx/";
a.evalScript('$._ext.evalFiles("'+c+'")')}

function evalScript(a,c){(new CSInterface).evalScript(a,c)}
function openUrl(a){csInterface.openURLInDefaultBrowser(a)}

 

$(document).ready(function(){loadJSX();

$("#1d-1").button().click(function(a){csInterface.evalScript('$._ext.evalFile("'+extensionRoot+'1d-1.jsx")')});

 

 

I don't understand every line of it but it does work.

 

As well as having the /jsx/ folder in the extension i'd like to use other path.

The user folder.

/user/Creative\ Cloud\ files/folder1/jsx

 

 

This topic has been closed for replies.

1 reply

Ten A
Community Expert
Community Expert
September 27, 2019

if you want to put scripts under the Creative Cloud folder, Your path is "/users/<USER_NAME>/Creative Cloud Files/folder1/jsx".
You can get user's Document folders path and remove Document like below snipet.

csi.getSystemPath(SystemPath.MY_DOCUMENTS).match(/(.+)(Documents)/);
alert(RegExp.$1+"Creative Cloud files/folder1/jsx");

ex.

USER_DATA userData (/users/Library/Application Support)
COMMON_FILES commonFiles (/Library/Application Support)
MY_DOCUMENTS myDocuments (/users/<USER_NAME>/Documents)
APPLICATION application (/Library/Application Support/Adobe/CEP/Extensions/<EXT_NAME>)
EXTENSION extension (/Library/Application Support/Adobe/CEP/Extensions/<EXT_NAME>)
HOST_APPLICATION hostApplication (HOST_APPS_PATH)

These are SystemPath's parameters you can use.

Known Participant
September 27, 2019

i don’t really understand the code I’m using. I’ve edited the paths to work for me but I don’t understand it well enough to add a new function.

 

I want to keep my old path for LoadJSX and add a second.

 

This is the code i'm using to load each jsx

$(document).ready(function(){loadJSX();
                             
                             $("#1d-1").button().click(function(a){csInterface.evalScript('$._ext.evalFile("'+extensionRoot+'1d-1.jsx")')});

Above that i have extensionRoot defined as a var.

var extensionRoot=csInterface.getSystemPath(SystemPath.EXTENSION)+"/jsx/";

 

I tried changing your code to

var cloudPath=csInterface.getSystemPath(SystemPath.MY_DOCUMENTS).match(/(.+)(Documents)/);
alert(RegExp.$1+"Creative\ Cloud\ files/Folder1");

 

and the launch code for each script to

$(document).ready(function(){loadJSX();
                                 $("#1a-1").button().click(function(a){csInterface.evalScript('$._ext.evalFile("'+cloudPath+'1a-1.jsx")')});

 

I get an error when i open the panel though.

JavaScript Alert - file:///Users/david/Library/Application%20Support/Adobe/CEP/extensions/Panel2/index.html

/Users/david/Creative Cloud files/Folder1

 

Do i need to have them run under a different function? I'm using the same loadJSX as before.

function loadJSX()
    {
    var a=new CSInterface,c=a.getSystemPath(SystemPath.EXTENSION)+"/jsx/";
    a.evalScript('$._ext.evalFiles("'+c+'")')}

function evalScript(a,c){(new CSInterface).evalScript(a,c)}
function openUrl(a){csInterface.openURLInDefaultBrowser(a)}

 

Known Participant
September 30, 2019
Where is your jsx path you really need to run?

Where on the computer? As in the path?

or

Where in the code?

This is my original code

 

var csInterface=new CSInterface,gExtensionId="testPanel", event=new CSEvent("com.adobe.PhotoshopPersistent","APPLICATION");


event.extensionId=gExtensionId;csInterface.dispatchEvent(event);

function onLoaded(){
var a=new CSInterface;b=a.hostEnvironment.appName;"FLPR"!=b&&loadJSX();
for(var c=["PHXS"],e=0;e<c.length;e++){var d=c[e];if(0<=b.indexOf(d)&&(d=document.getElementById("btn_"+d)))d.disabled=!1}updateThemeWithAppSkinInfo(a.hostEnvironment.appSkinInfo);
a.addEventListener(CSInterface.THEME_COLOR_CHANGED_EVENT,onAppThemeColorChanged)}

var extensionRoot=csInterface.getSystemPath(SystemPath.EXTENSION)+"/jsx/scripts/";


function loadJSX()
{
var a=new CSInterface,c=a.getSystemPath(SystemPath.EXTENSION)+"/jsx/";
a.evalScript('$._ext.evalFiles("'+c+'")')}

function evalScript(a,c){(new CSInterface).evalScript(a,c)}
function openUrl(a){csInterface.openURLInDefaultBrowser(a)}

 

$(document).ready(function(){loadJSX();

$("#1d-1").button().click(function(a){csInterface.evalScript('$._ext.evalFile("'+extensionRoot+'1d-1.jsx")')});

 

 

I then added your lines but I get the error mentioned above.