使用 Applescript 编写 Photoshop 脚本 —无法使用“选择文件”打开图像
我知道我在这里错过了一些非常简单的东西,但我不知道它是什么。如果我使用以下脚本:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于某种原因,Photoshop CS5.1 放弃了对打开基于别名的文件引用的支持。
您需要将路径转换为字符串,并在 myFile 变量前添加 file 前缀。
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.
它适用于 Photoshop CS3。我没有CS5所以无法测试。
一个更简单的选择是使用:
您也可以尝试 Automator。
It works in Photoshop CS3. I don't have CS5 so I can't test it.
An easier alternative would be to use:
You could also try Automator.