Script engines
Script engines
Im currently tinkering with some ScriptUI to add to my scripts… Im doing this across the 'Suite' so my question is not just related to Photoshop but more the toolkit in general. When in ESTK I notice that there is only the one engine 'main' when Photoshop is the target app, with Illustrator there's two 'main' & some 'stagemanager blah blah', then Indesign has about 4 or 5 including one 'session' which a sample I've read uses #targetengine 'session'; where do I find info on… what, why and where to use these? So far I have been able to make simple window 'palettes' for every app except Photoshop? Window 'dialogs' are ok but with a palette I just get the briefest blink then gone? Am I doing something wrong?
Script engines
I can't answer the engine questions but in Photoshop palette type dialogs only display while the script is running. If all the script does is create the window, show it, then end you will only see the window flash at best.
Which make ScriptUI palette type dialogs limited to progress bars and such in Photoshop.
Which make ScriptUI palette type dialogs limited to progress bars and such in Photoshop.
Script engines
Hum… strange that the same palette just hangs about in Illustrator, Bridge & InDesign until I dismiss it in the top bar… I just added a $.sleep() to Photoshop just so I can see it constructed… Not got to making progress bars just yet… I couldn't find anything in the documents as to the purpose of these 'engines' and why they differ from app to app… Maybe I don't need to know anything about them?
Script engines
larsen67 wrote:Maybe I don't need to know anything about them?
As far as I can tell Photoshop only has one engine so knowledge about engines isn't helpful when scripting Photoshop. Although I am aware that other apps may have more than one engine I don't know much about using different engines as I mostly script for Photoshop.
I would think if you script for other Adobe apps knowledge about when and why to use a different engine would be helpful.
There is a sample script that shows how to create a palette window. It is named 'SnpCreateDialog.jsx' and can be found in the ESKT SDK. If you run it in ESTK with ESTK as the target app it shows the window. You can even close or overwrite the script in ESTK and the window remains showing. But run it with Photoshop as the target and you will not see the window.
Even if you make a startup script for Photoshop ( so the code stays in memory during a Photoshop session ) similar to the one below when you call the show function you only see a flash as the window is created then destroyed when the script ends.
Code: Select allvar mikesPalette = {};
mikesPalette.showPalette = function(){
var win = new Window("palette", "SnpCreateDialog",[100,100,380,245]); // bounds = [left, top, right, bottom]
this.windowRef = win;
// Add a frame for the contents.
win.btnPanel = win.add("panel", [25,15,255,130], "SnpCreateDialog");
// Add the components, two buttons
win.btnPanel.okBtn = win.btnPanel.add("button", [15,65,105,85], "OK");
win.btnPanel.cancelBtn = win.btnPanel.add("button", [120, 65, 210, 85], "Cancel");
// Register event listeners that define the button behavior
win.btnPanel.okBtn.onClick = function() {
win.close();
};
win.btnPanel.cancelBtn.onClick = function() {
win.close();
};
// Display the window
win.show();
};
As far as I can tell Photoshop only has one engine so knowledge about engines isn't helpful when scripting Photoshop. Although I am aware that other apps may have more than one engine I don't know much about using different engines as I mostly script for Photoshop.
I would think if you script for other Adobe apps knowledge about when and why to use a different engine would be helpful.
There is a sample script that shows how to create a palette window. It is named 'SnpCreateDialog.jsx' and can be found in the ESKT SDK. If you run it in ESTK with ESTK as the target app it shows the window. You can even close or overwrite the script in ESTK and the window remains showing. But run it with Photoshop as the target and you will not see the window.
Even if you make a startup script for Photoshop ( so the code stays in memory during a Photoshop session ) similar to the one below when you call the show function you only see a flash as the window is created then destroyed when the script ends.
Code: Select allvar mikesPalette = {};
mikesPalette.showPalette = function(){
var win = new Window("palette", "SnpCreateDialog",[100,100,380,245]); // bounds = [left, top, right, bottom]
this.windowRef = win;
// Add a frame for the contents.
win.btnPanel = win.add("panel", [25,15,255,130], "SnpCreateDialog");
// Add the components, two buttons
win.btnPanel.okBtn = win.btnPanel.add("button", [15,65,105,85], "OK");
win.btnPanel.cancelBtn = win.btnPanel.add("button", [120, 65, 210, 85], "Cancel");
// Register event listeners that define the button behavior
win.btnPanel.okBtn.onClick = function() {
win.close();
};
win.btnPanel.cancelBtn.onClick = function() {
win.close();
};
// Display the window
win.show();
};
Script engines
Mike, the sample is probably very similar to what Im tinkering about with at present… I can make palettes that are nothing more than a button list with each on.click() having a $.evalFile() these work as I would expect with the exception of Photoshop… I will just put it down to one of those this you can't do and not something I got wrong. I get this in Bridge where I will probably use these most…
from this sort of thing…
Code: Select all#target bridge
var psPal = new Window('palette');
psPal.preferredSize = [150,200];
psPal.opacity = 0.9;
var red = 0, green = (1/256)*102, blue = (1/256)*153;
psPal.graphics.backgroundColor = psPal.graphics.newBrush
(psPal.graphics.BrushType.SOLID_COLOR,[red, green, blue]);
var psI = File('~/Desktop/PS_Icons/PS_AppIcon.png');
psPal.add('image',undefined,psI);
var messText = psPal.add('statictext');
messText.text = 'Run Script…';
messText.graphics.font = ScriptUI.newFont('Helvetica', 'Bold', 14);
messText.graphics.foregroundColor = messText.graphics.newPen
(messText.graphics.PenType.SOLID_COLOR, [1.0, 1.0, 1.0], 1);
var buttA = psPal.add('button',undefined,'Script A');
var buttB = psPal.add('button',undefined,'Script B');
var buttC = psPal.add('button',undefined,'Script C');
var buttD = psPal.add('button',undefined,'Script D');
var buttE = psPal.add('button',undefined,'Script E');
var buttF = psPal.add('button',undefined,'Script F');
psPal.center();
psPal.show();
buttA.onClick = function() {
var f = File('~/Desktop/TestA.jsx');
$.evalFile(f);
};
buttB.onClick = function() {
var f = File('~/Desktop/TestB.jsx');
$.evalFile(f);
};
buttC.onClick = function() {
var f = File('~/Desktop/TestC.jsx');
$.evalFile(f);
};
buttD.onClick = function() {
var f = File('~/Desktop/TestD.jsx');
$.evalFile(f);
};
buttE.onClick = function() {
var f = File('~/Desktop/TestE.jsx');
$.evalFile(f);
};
buttF.onClick = function() {
var f = File('~/Desktop/TestF.jsx');
$.evalFile(f);
};
from this sort of thing…
Code: Select all#target bridge
var psPal = new Window('palette');
psPal.preferredSize = [150,200];
psPal.opacity = 0.9;
var red = 0, green = (1/256)*102, blue = (1/256)*153;
psPal.graphics.backgroundColor = psPal.graphics.newBrush
(psPal.graphics.BrushType.SOLID_COLOR,[red, green, blue]);
var psI = File('~/Desktop/PS_Icons/PS_AppIcon.png');
psPal.add('image',undefined,psI);
var messText = psPal.add('statictext');
messText.text = 'Run Script…';
messText.graphics.font = ScriptUI.newFont('Helvetica', 'Bold', 14);
messText.graphics.foregroundColor = messText.graphics.newPen
(messText.graphics.PenType.SOLID_COLOR, [1.0, 1.0, 1.0], 1);
var buttA = psPal.add('button',undefined,'Script A');
var buttB = psPal.add('button',undefined,'Script B');
var buttC = psPal.add('button',undefined,'Script C');
var buttD = psPal.add('button',undefined,'Script D');
var buttE = psPal.add('button',undefined,'Script E');
var buttF = psPal.add('button',undefined,'Script F');
psPal.center();
psPal.show();
buttA.onClick = function() {
var f = File('~/Desktop/TestA.jsx');
$.evalFile(f);
};
buttB.onClick = function() {
var f = File('~/Desktop/TestB.jsx');
$.evalFile(f);
};
buttC.onClick = function() {
var f = File('~/Desktop/TestC.jsx');
$.evalFile(f);
};
buttD.onClick = function() {
var f = File('~/Desktop/TestD.jsx');
$.evalFile(f);
};
buttE.onClick = function() {
var f = File('~/Desktop/TestE.jsx');
$.evalFile(f);
};
buttF.onClick = function() {
var f = File('~/Desktop/TestF.jsx');
$.evalFile(f);
};