首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用applescript在photoshop (cs5)中获取当前打开的文件的路径?

如何使用applescript在photoshop (cs5)中获取当前打开的文件的路径?
EN

Stack Overflow用户
提问于 2011-06-24 15:50:51
回答 1查看 4K关注 0票数 6

如何使用applescript在photoshop (cs5)中获取当前打开的文件的路径?

我在MacOSX10.7上使用CS5

我尝试了下面的答案,它在Applescript编辑器中给出了以下错误:

代码语言:javascript
运行
复制
error "Adobe Photoshop CS5 got an error: Can’t get document 1.
Invalid index." number -1719 from document 1
EN

回答 1

Stack Overflow用户

发布于 2011-06-24 18:55:26

更新:--我已经在CS5和MacOS10.7中测试了下面的代码,并且可以确认,即使简单地将tell application "Adobe Photoshop CS4"切换到tell application "Adobe Photoshop CS5",这也是可行的。您所得到的错误是由于您的目标是文档1而不是首先打开的文档所造成的。您可以使用以下方法轻松地检查这一点:

代码语言:javascript
运行
复制
tell application "Adobe Photoshop CS5"
    set documentCount to count documents
    if documentCount > 0 then
        set theDocument to document 1
        set theFilePath to file path of theDocument
        return theFilePath
    else
        -- no documents open. what to do?
    end if
end tell

以前的回答是:--我还没有CS5 (还没有),但这里是给CS4的,我想CS5的版本不会有太大的不同,如果有的话,因为已经很好地规范了CS3之后的API:

代码语言:javascript
运行
复制
tell application "Adobe Photoshop CS4"
    set theDocument to document 1
    set theFilePath to file path of theDocument
    return theFilePath
end tell
--> Result: Macintosh HD:path:to:file:filename.ext
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6470379

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档