您好,我怎样才能在jsx脚本中运行Photoshop中的“Free Transform”。我使用了Script Listener中收到的代码,但是这段代码给出了一个错误:
错误8800:发生一般Photoshop错误。此版本的Photoshop可能无法使用此功能。 - 命令“”目前不可用。行:73 - > executeAction(idinvokeCommand,desc3666,DialogModes.NO);
这段代码:
// =======================================================
var idinvokeCommand = stringIDToTypeID( "invokeCommand" );
var desc3666 = new ActionDescriptor();
var idcommandID = stringIDToTypeID( "commandID" );
desc3666.putInteger( idcommandID, 2207 );
var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );
desc3666.putBoolean( idkcanDispatchWhileModal, true );
executeAction( idinvokeCommand, desc3666, DialogModes.NO );
// =======================================================
var idtoolModalStateChanged = stringIDToTypeID( "toolModalStateChanged" );
var desc3667 = new ActionDescriptor();
var idLvl = charIDToTypeID( "Lvl " );
desc3667.putInteger( idLvl, 1 );
var idStte = charIDToTypeID( "Stte" );
var idStte = charIDToTypeID( "Stte" );
var identer = stringIDToTypeID( "enter" );
desc3667.putEnumerated( idStte, idStte, identer );
var idTool = charIDToTypeID( "Tool" );
var desc3668 = new ActionDescriptor();
var idIdnt = charIDToTypeID( "Idnt" );
desc3668.putString( idIdnt, """laso""" );
var idTtl = charIDToTypeID( "Ttl " );
desc3668.putString( idTtl, """Lasso Tool""" );
var idTool = charIDToTypeID( "Tool" );
desc3667.putObject( idTool, idTool, desc3668 );
var idKnd = charIDToTypeID( "Knd " );
var idKnd = charIDToTypeID( "Knd " );
var idTool = charIDToTypeID( "Tool" );
desc3667.putEnumerated( idKnd, idKnd, idTool );
var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );
desc3667.putBoolean( idkcanDispatchWhileModal, true );
executeAction( idtoolModalStateChanged, desc3667, DialogModes.NO );
上面的代码不会触发Transform操作:你通常可以在ScriptListener日志文件中看到一些关于所用操作的提示 - 在转换的情况下它是描述符的名称:Trnf
- 这里我们看到调用模态和使用套索工具?或类似的东西。实际上所有使用DispatchWhileModal
和toolModalState
的代码都不能在PS中运行并且可以被忽略(它可能用于调试)。
我认为从Scriptlistener获取大量代码的最简单方法是删除日志文件,使用特定值执行所需操作,然后在新创建的日志文件中搜索这些值。
Sergey Kritskiy,谢谢你的回答。
这段代码工作:
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
function InteractiveTransform() {
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(cTID('Mn '), cTID('MnIt'), cTID('FrTr'));
desc1.putReference(cTID('null'), ref1);
executeAction(cTID('slct'), desc1, DialogModes.NO);
};