Photoshop Javascript 图像在显示警告框之前未在屏幕上渲染



我是这里的新手,也是脚本编写的新手。 我正在为我们的图像处理团队编写一个脚本,其中包含一个组件,该组件要求用户在关闭文档之前确认前景色和背景色。我似乎无法解决的问题是脚本正在处理所有功能,最后写有警报,但是用户应该看到的最终图像不会在警报框弹出并暂停代码之前呈现警报框。下面是完整代码的示例。任何帮助或建议将不胜感激。

#target photoshop
app.bringToFront();
var docRef = app.activeDocument;
var selRefMain = docRef.selection;
checkColors();
function checkColors() 
    docRef.resizeImage(800, 800, 72, ResampleMethod.BICUBIC); 
    var selBoundsFg = Array(Array(0, 0), Array(800, 800), Array(0, 800)); //creates bounds for Foreground color selection
    var selBoundsBg = Array(Array(0, 0), Array(800, 800), Array(800, 0));//creates bounds for background color selection
    selRefMain.select (selBoundsFg);
    selRefMain.fill(app.foregroundColor);
    selRefMain.select (selBoundsBg);
    selRefMain.fill(app.backgroundColor);
    selRefMain.deselect();
};
alert ("Please check Foredround and Background colors");

一种方法是等待重绘:

var desc = new ActionDescriptor();
desc.putEnumerated(charIDToTypeID("Stte"), charIDToTypeID("Stte"), charIDToTypeID("RdCm"));
executeAction(charIDToTypeID("Wait"), desc, DialogModes.NO);

这是从 stdlib.js 的第 8273 行中提取的。

最新更新