window of the desktop
比较残废。拿不到它index
的Finder windows
不包括桌面窗口,所以我无法检查它是否是第一个。index of the first Finder window
无论桌面是否具有焦点,都是 1。(只要存在其他 Finder 窗口,否则它将失败。)
问问题
1319 次
3 回答
4
看起来该insertion location
物业很接近,也许足够接近。
insertion location (specifier, r/o) : the container in which a new folder would appear if “New Folder” was selected
tell application "Finder"
get insertion location
end tell
Result:
folder "Desktop" of folder "nad" of folder "Users" of startup disk of application "Finder"
但是,如果焦点在打开到桌面文件夹的 Finder 窗口上,则存在歧义。这给出了与焦点在桌面背景上相同的结果。但也许这对你想做的事情并不重要。
于 2010-08-15T01:47:02.097 回答
0
看起来你可以检查选择...
set desktopIsFrontmost to false
tell application "Finder"
if selection is {} then set desktopIsFrontmost to true
end tell
return desktopIsFrontmost
于 2010-08-15T06:35:55.093 回答
0
使用 Ned 的回答,这是我想出的(在 rb-appscript 中):
#!/usr/bin/env ruby
# encoding: UTF-8
require 'pathname'
require 'appscript'
include Appscript
path_to_desktop = Pathname.new "#{ENV['HOME']}/Desktop"
path_of_insertion_location = Pathname.new app("Finder").insertion_location.get(:result_type => :file_ref).get(:result_type => :alias).path
path_of_first_finder_window = Pathname.new app("Finder").Finder_windows.first.target.get(:result_type => :alias).path rescue nil
is_desktop_the_active_view = path_to_desktop == path_of_insertion_location && path_of_first_finder_window != path_to_desktop
于 2010-08-23T09:36:40.967 回答