运行Photoshop的“动作";从Javascript脚本 [英] Running a Photoshop "Action" from a Javascript Script

查看:73
本文介绍了运行Photoshop的“动作";从Javascript脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写Photoshop脚本以打开一些图像并对它们执行一些操作.到现在为止还挺好.我需要该脚本来播放以前记录在Photoshop中的给定 Action .

I´m writing a Photoshop script to open some images and do some things on them. So far so good. I need the script to play a given Action previously recorded on Photoshop.

如何从Javascript代码调用和播放Photoshop Action?

我正在寻找类似的东西:

I´m looking for something like:

app.actions["actionName"].play()
app.actions["actionName"].onComplete(function(){/*do stuff when finished*/})

(将操作转换为JS代码不是我的应用程序的选择)

(Translating the action into JS code is not an option for my application)

推荐答案

我认为您正在寻找的代码是:

The code i believe you are looking for is this:

app.doAction("ActionStep","ActionFile.ATN")

您将要确保ATN文件已经加载到photoshops操作面板中,"ActionStep"将是您要运行的步骤的名称,而"ActionFile.ATN"是该步骤要执行的操作文件位于.

your gonna want to make sure the ATN file is already loaded into photoshops action palette, "ActionStep" is gonna be the name of the step you want to run, and "ActionFile.ATN" is the Action file that the step is located in.

您可以走得更远,甚至可以添加错误处理

you could go a bit further and even add in error handling

try{
//Code you want to execute
app.doAction("ActionStep","ActionFile.ATN")
}catch(e){
//If Code didn't execute then goes here, and executes code within this block
...Code...
}finally{
//executes this code immediately after try block, if error is thrown then is executed after catch block This block is optional and is not necessary.
...Code...
}

这篇关于运行Photoshop的“动作";从Javascript脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆