AppleScript:Finder:如何判断桌面是否具有焦点?
桌面窗口
相当残破。无法获取其索引
。Finder 窗口
不包括桌面窗口,因此我无法检查它是否是第一个窗口。- 无论桌面是否具有焦点,
第一个 Finder 窗口的索引
均为 1。 (只要存在其他Finder窗口,否则会失败。)
window of the desktop
is rather crippled. Can't get itsindex
.Finder windows
does not include the desktop window, so I can't check that the it's the first there.index of the first Finder window
is 1 regardless of the desktop having focus. (as long as other Finder windows exist, otherwise it'll fail.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看起来
插入位置
属性很接近,也许足够接近。但是,如果焦点位于打开到桌面文件夹的 Finder 窗口上,则存在歧义。这会产生与焦点位于桌面背景相同的结果。但也许这对于你想做的事情并不重要。
Looks like the
insertion location
property comes close, maybe close enough.There's an ambiguity, though, if the focus is on a Finder window opened to the Desktop folder; that gives the same result as if the focus is on the Desktop background. But maybe that doesn't matter for what you want to do.
看来你可以检查一下选择...
It looks like you can just check the selection...
使用内德的答案,这就是我想到的(在 rb-appscript 中):
Using Ned's answer, here's what I came up with (in rb-appscript):