有同樣的問題,並通過封閉單擊導致延遲解決它ignoring application responses
塊。這裏是一個快速摘要:
OLD CODE(原因6秒延時)
tell application "System Events" to tell process "SystemUIServer"
set bt to (first menu bar item whose description is "bluetooth") of menu bar 1
click bt
tell (first menu item whose title is "SBH80") of menu of bt
click
tell menu 1
if exists menu item "Disconnect" then
click menu item "Disconnect"
else
click menu item "Connect"
end if
end tell
end tell
end tell
新代碼(沒有延遲)
tell application "System Events" to tell process "SystemUIServer"
set bt to (first menu bar item whose description is "bluetooth") of menu bar 1
ignoring application responses
click bt
end ignoring
end tell
do shell script "killall System\\ Events"
delay 0.1
tell application "System Events" to tell process "SystemUIServer"
tell (first menu item whose title is "SBH80") of menu of bt
click
tell menu 1
if exists menu item "Disconnect" then
click menu item "Disconnect"
else
click menu item "Connect"
end if
end tell
end tell
end tell
請檢查下面列出的線程詳細的解答。
Speed up AppleScript UI scripting?
希望這會有所幫助。
我知道這聽起來很瘋狂,但是如果你在'click button'命令之後添加'delay 1'命令,它會有幫助嗎? – matt 2013-04-21 03:29:58
不,它沒有,謝謝你的建議。 – vcirilli 2013-04-21 20:04:05
它可能不會有所作爲,但是您是否嘗試用'perform action「AXPress」of'替換'click'?如果有用於顯示該窗口的菜單欄項目? – user495470 2013-04-21 23:51:52