使用 Applescript 编写 Photoshop 脚本 —无法使用“选择文件”打开图像

发布于 2024-12-22 23:51:14 字数 461 浏览 1 评论 0原文

我知道我在这里错过了一些非常简单的东西,但我不知道它是什么。如果我使用以下脚本:

tell application "Adobe Photoshop CS5.1"
open file "path:to:some:file"
end tell

它工作没有问题,但如果我尝试使用“选择文件”对话框,一切都会崩溃:

tell application "Adobe Photoshop CS5.1"
    set myFile to choose file
    open myFile
end tell

我收到错误

error "Adobe Photoshop CS5.1 got an error: File some object wasn’t found." number -43

我在这里缺少什么?

I know I'm missing something incredibly simple here, but I can't figure out what it is. If I use the following script:

tell application "Adobe Photoshop CS5.1"
open file "path:to:some:file"
end tell

it works no problem, but if I try to use the "choose file" dialog everything falls apart:

tell application "Adobe Photoshop CS5.1"
    set myFile to choose file
    open myFile
end tell

I get an error

error "Adobe Photoshop CS5.1 got an error: File some object wasn’t found." number -43

What am I missing here?

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

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

发布评论

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

评论(2

舂唻埖巳落 2024-12-29 23:51:14

由于某种原因,Photoshop CS5.1 放弃了对打开基于别名的文件引用的支持。

您需要将路径转换为字符串,并在 myFile 变量前添加 file 前缀。

tell application "Adobe Photoshop CS5.1"
    set myFile to (choose file) as string
    open file myFile
end tell

For some reason, Photoshop CS5.1 dropped support for opening alias based file references.

You'll need to convert the path to a string and prefix the myFile variable with file.

tell application "Adobe Photoshop CS5.1"
    set myFile to (choose file) as string
    open file myFile
end tell
叹梦 2024-12-29 23:51:14

它适用于 Photoshop CS3。我没有CS5所以无法测试。

一个更简单的选择是使用:

tell application "Adobe Photoshop CS3"
activate
tell application "System Events"
key code 31 using command down
end tell
end tell

您也可以尝试 Automator。

It works in Photoshop CS3. I don't have CS5 so I can't test it.

An easier alternative would be to use:

tell application "Adobe Photoshop CS3"
activate
tell application "System Events"
key code 31 using command down
end tell
end tell

You could also try Automator.

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