基本上,我有这个简短的脚本来“清理”桌面。这是代码:
tell application "System Events"
tell application "Finder" to activate desktop
delay 0.1
tell process "Finder" to click menu item "Clean Up" of menu "View" of menu bar item "View" of front menu bar
end tell
没有Finder窗口打开时,脚本工作正常。但是,如果至少有一个Finder窗口,那么该行 tell application "Finder" to activate desktop
运行时,它会使该窗口处于活动状态,而不是桌面。
这是什么原因?将焦点放在桌面上的正确方法是什么(与点击桌面图像相同的效果)?
(在El Capitan上这样做)
keystroke "<" using command down
同tell process "Finder" to click menu item "Cycle Through Windows" of menu "Window" of menu bar item "Window" of front menu bar