1.动作已经存在PS动作面板,直接播放
app.doAction("Action 2","Set 2");
动作管理器用法
play_action("默认动作", "存储为 Photoshop PDF")
//Examples of using:
//play_action("Set 1", "Action 1") // Perform the whole action// 执行整个动作
//play_action("Set 1", "Action 1", 4, true) // Complete all from the beginning of the command number 4// 从命令编号4 的开头全部完成
//play_action("Set 1", "Action 1", 5, false) // Will execute only command number 5// 仅执行命令编号5
// cmd_number - the index of the command, ( starts from 1 )
function play_action(set, action, cmd_number, allow_continue)
{
try
{
var d = new ActionDescriptor();
var r = new ActionReference();
if (typeof(cmd_number) == "number") r.putIndex( charIDToTypeID( "Cmnd" ), cmd_number );
r.putName( charIDToTypeID( "Actn" ), action );
r.putName( charIDToTypeID( "ASet" ), set );
d.putReference( charIDToTypeID( "null" ), r );
if (typeof(allow_continue) == "boolean") d.putBoolean( charIDToTypeID( "Cntn" ), allow_continue );
executeAction( charIDToTypeID( "Ply " ), d, DialogModes.NO );
}
catch(e) { alert(e); }
}
2.动作不存在,先加载进PS动作面板在播放
app.load(File("C:\\2.atn"));
app.doAction(“Action 2”,“Set 2”);
3.动作不存在,不加载进PS动作面板,直接播放
app.bringToFront();
/*************************************************
Play a specific action contained in an actions file (.atn), without the need to load the file in the Actions Palette.
http://www.tonton-pixel.com/JSON%20Action%20Manager/jsDoc/symbols/jamActions.html
Utility script using the "JSON Action Manager" scripting library.
© 2011-2015 Michel MARIANI.
******************************************************/
//------------------------------------------------------------------------------
// jamActions.jsxinc v4.4 (minified)
if(typeof jamActions!=='object')
{
var jamActions={};
(function()
{
jamActions.isActionsFile=function(file)
{return(file.type==='8BAC')||file.name.match(/\.atn$/i);};
jamActions.isActionsPalette=function(file)
{return((file.type==='8BPF')&&file.name.match(/^Actions Palette$/i))||file.name.match(/^Actions Palette.psp$/i);};
function readBEInt(file,byteCount)
{var bytes=file.read(byteCount);
var intValue=0;
for(var index=0;index<byteCount;index++) {intValue=(intValue<<8)+bytes.charCodeA

本文介绍如何在Photoshop中通过脚本播放PS动作,包括已存在的动作、加载动作文件播放及直接读取.atn文件播放的方法。
最低0.47元/天 解锁文章
1万+





