3

我需要获取桌面上当前选定的项目或右键单击的桌面项目。根据此项目的路径,我将不得不执行一些操作。这可以使用applescript来完成吗???

我目前正在使用这里给出的逻辑(使用脚本桥)

但这似乎从任何查找器窗口中获取选择,而不仅仅是桌面视图。任何人都可以请提供任何替代方案吗?

4

2 回答 2

3

如果您首先关注桌面,则 selection 属性将仅包含在桌面上选择的项目。

tell application "Finder"
    select window of desktop
    selection
end tell
于 2012-02-20T14:37:27.280 回答
0

finder 无法分辨从桌面选择了哪些项目。它只能从活动窗口告诉你。如果您不想更改窗口的顺序,可以考虑使用 GUI 脚本。您将获得选定的项目,然后像这样

tell application "System Events"
    tell process "Finder"
        tell group 1 of scroll area 1
            get name of every image whose selected is true
        end tell
    end tell
end tell
于 2012-02-20T15:27:30.367 回答