在Google Chrome浏览器中(在Mac上),您可以通过从httpsp://google.com按下Command + Shift + Period来激活Google语音搜索。
假设网址http://google.com已加载在Chrome标签页中且搜索框处于焦点位置,那么以下AppleScript不应该有效吗?
tell application "Google Chrome"
activate
tell application "System Events" to keystroke "." using {command down, shift down}
end tell
由于某种原因它不起作用,我不明白为什么,因为以下脚本将按预期用文本填充搜索字段:
tell application "Google Chrome"
activate
tell application "System Events" to keystroke "this test works as expected"
end tell
如何使用脚本触发Google语音搜索?
答案 0 :(得分:3)
尝试:
tell application "Google Chrome" to activate
tell application "System Events"
key code 47 using {command down, shift down}
end tell
delay 3