Hello, I use AppleScripts to capture the name of the Paths of an image open in Photoshop and then use to put the names in a listbox, now would like to do this with Javascript, could someone help me with this because I know nothing of Javascript?
I appreciate any help!
Thank you.
Capture Pathitems Names with Javascript
-
pfaffenbichler
Capture Pathitems Names with Javascript
Does this help?
Code: Select all// 2014; use it at your own risk;
#target photoshop
// do the operation if everything has checked out;
if (app.documents.length > 0) {
if (app.activeDocument.pathItems.length > 0) {
app.activeDocument.suspendHistory("a", "main()")
}
};
////////////////////////////////////
////////////////////////////////////
////////////////////////////////////
function main() {
var myDocument = app.activeDocument;
////////////////////////////////////
// dialog for path-selection and stuff;
var dlg = new Window('dialog', "select path to distribute copies along", [500,300,840,685]);
dlg.pathList = dlg.add('listbox', [15,15,325,137], 'field', {multiselect: false});
// populate the list with the open files’ names;
for (var o = 0; o < myDocument.pathItems.length; o++) {
dlg.pathList.add ("item", myDocument.pathItems[o].name);
};
dlg.pathList.items[0].selected = true;
// buttons for ok, and cancel;
dlg.buttons = dlg.add('panel', [15,320,325,370], '');
dlg.buttons.buildBtn = dlg.buttons.add('button', [13,11,145,36], 'OK', {name:'ok'});
dlg.buttons.cancelBtn = dlg.buttons.add('button', [155,11,290,36], 'Cancel', {name:'cancel'});
// show the dialog;
dlg.center();
var myReturn = dlg.show ();
////////////////////////////////////
if (myReturn == true) {
alert (dlg.pathList.selection)
}
};
Code: Select all// 2014; use it at your own risk;
#target photoshop
// do the operation if everything has checked out;
if (app.documents.length > 0) {
if (app.activeDocument.pathItems.length > 0) {
app.activeDocument.suspendHistory("a", "main()")
}
};
////////////////////////////////////
////////////////////////////////////
////////////////////////////////////
function main() {
var myDocument = app.activeDocument;
////////////////////////////////////
// dialog for path-selection and stuff;
var dlg = new Window('dialog', "select path to distribute copies along", [500,300,840,685]);
dlg.pathList = dlg.add('listbox', [15,15,325,137], 'field', {multiselect: false});
// populate the list with the open files’ names;
for (var o = 0; o < myDocument.pathItems.length; o++) {
dlg.pathList.add ("item", myDocument.pathItems[o].name);
};
dlg.pathList.items[0].selected = true;
// buttons for ok, and cancel;
dlg.buttons = dlg.add('panel', [15,320,325,370], '');
dlg.buttons.buildBtn = dlg.buttons.add('button', [13,11,145,36], 'OK', {name:'ok'});
dlg.buttons.cancelBtn = dlg.buttons.add('button', [155,11,290,36], 'Cancel', {name:'cancel'});
// show the dialog;
dlg.center();
var myReturn = dlg.show ();
////////////////////////////////////
if (myReturn == true) {
alert (dlg.pathList.selection)
}
};