【问题标题】:Applescript: asking the Finder from ApplescriptObjC?Applescript:从 ApplescriptObjC 询问 Finder?
【发布时间】:2014-06-12 03:12:26
【问题描述】:

这个单行 Applescript 在我的 Mac 上运行良好:

tell application "Finder" to open POSIX file "/Development/Applescript/Rapport.docx"

但是它在一个琐碎的 ApplescriptObjC 项目中失败了:

on applicationWillFinishLaunching:aNotification
    -- Insert code here to initialize your application before any files are opened
        tell application "Finder" to open POSIX file "/Development/Applescript/Rapport.docx"
end applicationWillFinishLaunching:

我得到的错误是:

*** -[CMDAppDelegate applicationWillFinishLaunching:]: POSIX file "/Development/Applescript/Rapport.docx" of «script» doesn’t understand the “open” message. (error -1708)

我错过了什么?

【问题讨论】:

  • 请注意,Finder 将使用默认设置为打开该文件的任何应用程序打开该文件(在 Finder 中,请参阅文件>获取信息>打开方式)。如果要在 Word 中专门打开文件以进行进一步操作,请使用 tell application "Microsoft Word" to open [whatever]。 (或者,如果您想从 ObjC 打开文件,则根本不需要 AS;请参阅 NSWorkspaceLaunchServices。)

标签: applescript applescript-objc


【解决方案1】:

我曾经遇到过这个问题,我无法解释这种奇怪的行为,但对我进行了一些重新安排:

tell application "Finder" to open "/Development/Applescript/Rapport.docx" as POSIX file

【讨论】:

  • 概括地说,从 OS X 10.9.2 开始:"Finder" 的上下文中,始终使用 ... as POSIX file 形式而不是 POSIX file .... 为什么?只有 Apple 知道。
  • 不是 Finder 问题。 AppleScriptObjC 依靠一些邪恶的巫术将自己插入 AppleScript 运行时,从而阻止 AppleScript 正确解释 alias "..."POSIX file "..." 说明符。 AppleScript 工程师给出的,AppleScript 工程师拿走的。
猜你喜欢
  • 1970-01-01
  • 2015-04-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多