在 Photoshop 中编写创建动作的脚本

发布于 2024-10-17 09:01:27 字数 866 浏览 1 评论 0原文

我用 Photoshop 的 javascript 编写了一个文件导出器,它显示一个对话框并允许用户选择一些选项,然后导出到多个文件。我想在对话框中提供一个按钮,用于创建一个操作,并分配一个功能键快捷方式,以便随后通过按功能键来运行脚本。

通常,用户会手动创建操作,但我的大多数用户都不熟悉操作,我希望使工作流程尽可能简单。

所以。我使用 ScriptingListener.plugin 来获取手动创建操作时播放的操作(从操作面板;创建一个操作,命名它,选择一个功能键,点击“记录”,浏览到我的脚本,运行它,结束录音)这就是它记录的内容;

var id1 = stringIDToTypeID( "AdobeScriptAutomation Scripts" );
  var desc1 = new ActionDescriptor();
  var id2 = charIDToTypeID( "jsCt" );
  desc1.putPath( id2, new File( "/Users/stewart/Projects/Export.jsx" ) );
  var id3 = charIDToTypeID( "jsMs" );
  desc1.putString( id3, "undefined" );
executeAction( id1, desc1, DialogModes.YES );

这似乎只是运行脚本的代码,而不是创建操作的代码。

我此时的假设是,因为 ScriptingListener 无法捕获这些交互,所以编写脚本是不可能的。

我正在使用 Photoshop CS3 或更高版本。

是否可以编写一个脚本来创建一个将运行该脚本的操作(有效地为其自身安装一个操作)?

另外,脚本是否也可以为创建的Action指定快捷键?

I've written a file exporter in javascript for Photoshop which displays a dialog and allows the user to select some options then exports to multiple files. I'd like to provide a button in the dialog which creates an Action, and assigns a Function key shortcut to run the script afterwards by hitting the Function key.

Usually, the user would create the Action manually, but most of my users aren't familiar with Actions and I'd like to make the workflow as simple as possible.

So. I've used the ScriptingListener.plugin to grab the actions that are played when I manually create the Action (from the actions panel; create an action, name it, choose a function key, hit 'record', browse to my script, run it, end recording) and this is what it records;

var id1 = stringIDToTypeID( "AdobeScriptAutomation Scripts" );
  var desc1 = new ActionDescriptor();
  var id2 = charIDToTypeID( "jsCt" );
  desc1.putPath( id2, new File( "/Users/stewart/Projects/Export.jsx" ) );
  var id3 = charIDToTypeID( "jsMs" );
  desc1.putString( id3, "undefined" );
executeAction( id1, desc1, DialogModes.YES );

This appears to be just the code to run the script, but not the code to create the action.

My assumption at this point is that because the ScriptingListener doesn't capture these interactions, scripting this won't be possible.

I'm working with Photoshop CS3 or later.

Is it possible to write a script which creates an Action that will run the script (effectively installing an Action for itself)?

Further, can the script also assign a shortcut key for the created Action?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挖个坑埋了你 2024-10-24 09:01:27

好的。你已经有了一些脚本。但是您需要它来创建一个操作,该操作将执行该脚本并为其分配热键?似乎有点矫枉过正了。

我可能建议您创建一个操作手册,然后为每台计算机分配一个热键。
此外,如果所有计算机都在同一网络中,您可以在计算机的公共目录中共享脚本,并从网络路径执行脚本。因此,您不需要每次在使用它的每台计算机上手动更新它。

Ok. You already have some script. But you need it to create an action, which will execute this script and assign a hotkey for it? Seemed to be an overkill.

I may advice you create an Action manullay and then assign a hotkey for each computer.
Also, if all computers are in the same network, you may share your script in public directory from you machine and execute script from network path. Thus, you'll not need to update it manually every time on each computer, where it's used.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文