Hallgrimur Bjornsson, these are my findings.
This works:
var fileObj = cep.fs.showOpenDialog(); csInterface.evalScript("app.open(File('" + encodeURIComponent(fileObj.data[0]) + "'));");
This doesn't work:
// JS =============================== var fileObj = cep.fs.showOpenDialog(); // console.log(fileObj.data[0]); // logged successfully csInterface.evalScript("myOpen('" + fileObj.data[0] + "')"); // JSX =============================== function myOpen (filePath) { alert("IN JSX"); // never gets here. app.open(File(filePath)); }
(by "doesn't work" I mean that the Open Dialog keeps open and the wheel spins on and on, PS doesn't open the file and hangs).
This strangely works (just added an alert between the evalScript call):
var fileObj = cep.fs.showOpenDialog(); alert(fileObj.data[0]); csInterface.evalScript("app.open(File('" + encodeURIComponent(fileObj.data[0]) + "'));");
This doesn't work:
var fileObj = cep.fs.showOpenDialog(); window.setTimeout(csInterface.evalScript("myOpen('" + fileObj.data[0] + "')"), 3000);
Nor (strangely enough) this:
var fileObj = cep.fs.showOpenDialog(); csInterface.evalScript("helloWorld();"); // being helloWorld a dummy function in the JSX;
Also this doesn't work:
var fileObj = cep.fs.showOpenDialog(); csInterface.evalScript("$.sleep(1000); helloWorld()");
So it seems that the simple fact CEP is opening a dialog breaks all the subsequent evalScript functions call (except in case - see code chunk #1) where the evalScript argument is plain scripting.
Now, this makes impossible (to my tests) to open a Select File dialog in the middle of a script when a panel is involved, in a scenario like the one of Sebastien Piconnier here: https://forums.adobe.com/thread/1470536 where in Photoshop he needs to make a user select a File; then the script operates on the current opened file; then the script opens the user selected file and gets on.
I would have tried also with ExtendScript CEP events, but I've the problems I pointed out elsewhere with them (Events fire all together at the JSX function end).
We're eagerly waiting for the Team findings!
Best
Davide Barranca
---
www.davidebarranca.com
www.cs-extensions.com