如何运行Photoshop ScriptListener插件生成的代码?

时间:2018-10-28 17:02:38

标签: javascript adobe photoshop extendscript photoshop-script

我在运行ScriptListener插件记录的代码时遇到麻烦。我已将命令从日志复制到Extendscript Toolkit CC中,但是无论何时运行它们(无论是否具有功能),它们都将在executeAction代码行中失败,并说:“此功能可能在此版本的Photoshop”

这是我要运行的代码:

function pasteAsPath() {
    var idinvokeCommand = stringIDToTypeID( "invokeCommand" );
    var desc32 = new ActionDescriptor();
    var idcommandID = stringIDToTypeID( "commandID" );
    desc32.putInteger( idcommandID, 105 );
    var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );
    desc32.putBoolean( idkcanDispatchWhileModal, true );
    executeAction( idinvokeCommand, desc32, DialogModes.NO );

    // =======================================================
    var idmodalStateChanged = stringIDToTypeID( "modalStateChanged" );
    var desc33 = new ActionDescriptor();
    var idLvl = charIDToTypeID( "Lvl " );
    desc33.putInteger( idLvl, 1 );
    var idStte = charIDToTypeID( "Stte" );
    var idStte = charIDToTypeID( "Stte" );
    var identer = stringIDToTypeID( "enter" );
    desc33.putEnumerated( idStte, idStte, identer );
    var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );
    desc33.putBoolean( idkcanDispatchWhileModal, true );
    var idTtl = charIDToTypeID( "Ttl " );
    desc33.putString( idTtl, """Paste""" );
    executeAction( idmodalStateChanged, desc33, DialogModes.NO );

    // =======================================================
    var idmodalStateChanged = stringIDToTypeID( "modalStateChanged" );
    var desc34 = new ActionDescriptor();
    var idLvl = charIDToTypeID( "Lvl " );
    desc34.putInteger( idLvl, 0 );
    var idStte = charIDToTypeID( "Stte" );
    var idStte = charIDToTypeID( "Stte" );
    var idexit = stringIDToTypeID( "exit" );
    desc34.putEnumerated( idStte, idStte, idexit );
    var idkcanDispatchWhileModal = stringIDToTypeID( "kcanDispatchWhileModal" );
    desc34.putBoolean( idkcanDispatchWhileModal, true );
    var idTtl = charIDToTypeID( "Ttl " );
    desc34.putString( idTtl, """Paste""" );
    executeAction( idmodalStateChanged, desc34, DialogModes.NO );

    // =======================================================
    var idpast = charIDToTypeID( "past" );
    var desc35 = new ActionDescriptor();
    var idAs = charIDToTypeID( "As  " );
    var idPath = charIDToTypeID( "Path" );
    desc35.putClass( idAs, idPath );
    executeAction( idpast, desc35, DialogModes.NO );
}

在Extendscript Toolkit CC中,我的目标是Photoshop,脚本文件的顶部也有#target photoshop,但它总是在executeAction处失败。未记录的命令可以正常工作,只有在运行已记录的命令时才会出现错误。

有人知道为什么会这样吗?我一直在浏览文档,SO和博客,但找不到实现此目的的方向,因此将不胜感激。

1 个答案:

答案 0 :(得分:0)

尝试删除所有invokeCommandmodalStateChanged块。从脚本启动时,它们什么都不做:我认为它们仅在CC2015之后才出现。基本上,这些只是表明有一个模态窗口出现,然后关闭了。