2012-12-10 35 views
4

在Google Chrome瀏覽器(Mac)中,您可以通過從htttp://google.com按下Command + Shift + Period來激活Google語音搜索。用於觸發Google Chrome語音搜索鍵盤快捷鍵的OSX腳本

假設url 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 

我怎樣才能觸發谷歌用腳本語音搜索?

回答

3

嘗試:

tell application "Google Chrome" to activate 
tell application "System Events" 
    key code 47 using {command down, shift down} 
end tell 
delay 3 
+0

的感謝!這很好 – user1385729