使用Applescript在桌面上获取选定/点击的项目
问题描述:
我需要获取桌面上当前选定的项目或右键单击的桌面项目。根据这个项目的路径,我将不得不执行一些操作。这可以使用applescript完成吗?使用Applescript在桌面上获取选定/点击的项目
我目前使用
(使用脚本桥)给出here逻辑但这似乎从任何Finder窗口,而不仅仅是在桌面视图获取的选择。任何人都可以提供任何替代品?
答
如果您首先关注桌面,则选择属性将仅包含桌面上选定的项目。
tell application "Finder"
select window of desktop
selection
end tell
答
查找程序无法确定从桌面中选择了哪些项目。它只能从活动窗口告诉你。如果你不想改变窗口的顺序,你可以考虑使用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-05-21 12:31:48