我正在为Adobe Bridge CS6开发脚本。目前,我想要做的就是访问用户选择的缩略图的大小(宽度和高度)并在弹出窗口或控制台上显示它。这是我的剧本:
function TestBridge() {
this.requiredContext = "\tAdobe Bridge must be running.\n\tExecute against Bridge as the Target.\n";
}
TestBridge.prototype.run = function() {
if(!this.canRun())
{
return false;
}
var selectedThumbnails = app.document.getSelection();
if (selectedThumbnails.length > 0) {
$.writeln("MEEEEEPT");
var thumb = selectedThumbnails[0];
var x = thumb.core.preview.preview.width;
var y = thumb.core.preview.preview.height;
//alert('MEEEEEPT: x = ' + x + ', y = ' + y);
$.writeln("MEEEEEPT: x = " + x + ", y = " + y);
return true;
}
$.writeln("MOOO");
return false;
}
TestBridge.prototype.canRun = function()
{
// Must be running in Bridge & have a selection
if( (BridgeTalk.appName == "bridge") && (app.document.selectionLength == 1)) {
return true;
}
// Fail if these preconditions are not met.
// Bridge must be running,
// There must be a selection.
$.writeln("ERROR:: Cannot run.");
$.writeln(this.requiredContext);
return false;
}
唯一的问题是......好吧,它不起作用。我在ExtendScript Toolkit上打开它,将目标设置为Bridge CS6,点击&#34;运行&#34; ...所有发生的事情是控制台说&#34;结果:canRun()&#34;。< / p>
查看Adobe的其他代码示例,我看到他们脚本的结构与我的几乎相同,所以我不知道自己做错了什么。
编辑:我需要的是在最后添加一行来调用函数,如下所示:
new.TestBridge.run();
愚蠢,愚蠢的错误。