简体   繁体   中英

How do I run code generated by the Photoshop ScriptListener plugin?

I am having trouble is running code recorded by the ScriptListener plugin. I've copied commands from the logs into Extendscript Toolkit CC, but any time I run them (with or without being a function) they all fail at the executeAction line of code and say "This functionality may not be available in this version of Photoshop"

This is the code I'm trying to run:

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 );
}

In Extendscript Toolkit CC I'm targeting Photoshop and also have #target photoshop at the top of the script file but it always fails at executeAction . Commands not recorded work fine, it is only when I run a recorded command that I get an error.

Does anyone know why this happens? I've been looking through documentation, SO, and blogs but cannot find direction for accomplishing this, so any help would be appreciated.

Try to remove all the invokeCommand and modalStateChanged blocks. Those don't do anything when launched from scripts: and I think they only started showing up after CC2015. Basically those just show that there was a modal window that appeared and then was closed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM