是的,它是可能的。您可以爲編輯文本框創建UI面板。這是你需要的基礎。
// dialogue
var dlg = new Window ("dialog", "Photoshop UI");
dlg.add ("statictext", undefined, "Do that thing");
var textContents = "No text";
// check to see if active layer is text
if (app.activeDocument.activeLayer.kind == "LayerKind.TEXT")
{
var textItemRef = app.activeDocument.activeLayer.textItem;
textContents = textItemRef.contents;
}
// add edit text
var edText = dlg.add ("edittext", [0,0,220,20]);
edText.text = textContents;
edText.alignment = "left";
edText.active = true;
//button group
var btnGroup = dlg.add ("group");
btnGroup.orientation = "row";
btnGroup.alignment = "center";
btnGroup.orientation = "column";
// add buttons
btnGroup.add ("button", undefined, "OK");
btnGroup.add ("button", undefined, "Cancel");
dlg.center();
var myReturn = dlg.show();
if (myReturn == 1)
{
// set checkboxes and input here
var ask = edText.text;
// call the function to change text
doThatThingThatYouDo(ask);
}
function doThatThingThatYouDo(str)
{
// check to see if active layer is text
if (app.activeDocument.activeLayer.kind == "LayerKind.TEXT")
{
var textItemRef = app.activeDocument.activeLayer.textItem;
textItemRef.contents = str;
}
alert(str);
}
用一些文本創建一個新的PSD,你會看到它在行動。它會在文本層讀取並允許您更改它。希望你會看到它是如何工作的,並將它用於你自己的項目。
取決於你使用的是哪個版本的Photoshop,但這可能是有用的:http://stackoverflow.com/questions/14571008/photoshop-scripting-changing-text-of-a-text-layer – Conan