您的脚本会打开 Spotlight菜单。打开 Spotlight窗口的键盘快捷键是command+ option+ space...
tell application "System Events" to keystroke space using {command down, option down}
更新:鉴于您修改后的答案,我编写了一个小脚本,应该可以满足您的需求...
set the searchText to the text returned of (display dialog "Enter the name of an item you wish to search for in Spotlight:" default answer "")
tell application "System Events"
keystroke space using {command down}
keystroke the searchText
--[1]
end tell
您可以在 [1] 处执行以下操作之一:
打开顶击:
keystroke return using {command down}
将选择移至下一个类别中的第一项:
keystroke (ASCII character 31) using {command down} --down arrow
将选择移动到上一个类别中的第一项:
keystroke (ASCII character 30) using {command down} --up arrow
将选择移动到整个菜单中的第一项:
keystroke (ASCII character 31) using {control down}
将选择移动到整个菜单中的最后一项:
keystroke (ASCII character 30) using {control down}