【问题标题】:show Finder file properties显示 Finder 文件属性
【发布时间】:2013-06-17 02:56:33
【问题描述】:

通过

ws = NSWorkspace.sharedWorkspace()
ws.selectFile_inFileViewerRootedAtPath_(filename, None)

我可以打开一个新的 Finder 窗口并选择特定文件。

现在我不仅要选择一个文件,还要打开该文件的 Finder 属性窗口。

有没有简单的方法可以做到这一点? (首选 Python 代码,但我可以自己翻译。)

【问题讨论】:

    标签: macos finder


    【解决方案1】:

    我不相信有任何 Cocoa API 可以直接执行此操作。但是,以下 AppleScript 可以完成这项工作:

    tell application "Finder"
        activate
        open information window of item 1 of (selection as list)
    end tell
    

    您可以使用NSAppleScriptosascript 命令调用它。在 Cocoa 中,您也可以使用 Scripting Bridge,但我不确定这对 Python 是否有帮助。 (稍微搜索一下 Apple 的文档,可以找到 py-appscript 的建议,以使用 Python 中的 Scripting Bridge。)

    【讨论】:

      猜你喜欢
      • 2012-08-06
      • 2011-07-08
      • 2015-10-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-03
      • 1970-01-01
      • 1970-01-01
      • 2011-07-11
      相关资源
      最近更新 更多