使用 NSWorkspace selectFile:inFileViewerRootedAtPath: 与桌面上的文件
您可以执行以下操作,让 Finder 打开一个窗口并选择一个文件:
[[NSWorkspace sharedWorkspace] selectFile:file inFileViewerRootedAtPath:root]
这对于大多数文件来说都很好,但据我所知,如果文件位于桌面上,Finder 仍会打开一个查看器窗口为此,即使您将桌面路径作为根传递。
有没有人想出一种方法让 Finder 只需选择桌面上的文件?
是否有一些偷偷摸摸的东西可以让人们以 root 身份说服 Finder 做明智的事情?
我想我可以写一个苹果脚本来做我想做的事,但我不禁觉得应该有一种更简单的方法......
You can do something like this to have the finder open a window and select a file:
[[NSWorkspace sharedWorkspace] selectFile:file inFileViewerRootedAtPath:root]
This is fine for most files, but as far as I can work out, if the file is on the desktop, the Finder will still open a viewer window for it, even if you pass the path to the desktop as the root.
Has anyone worked out a way to get the Finder to simply select the file on the desktop?
Is there something sneaky that one can pass as root to convince the Finder to do the sensible thing?
I imagine that I could write an applescript to do what I want, but I can't help feeling that there ought to be an easier way...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论