我在 Mac OS X 10.10 (Yosemite) 上使用 applescript。我注意到击键动作往往比 10.9 慢得多。
下面是我的applescript,它告诉终端输入“cd my current path in Finder
”并按return
:
tell application "Finder"
try
set currentFolder to (folder of the front window)
set currentPath to (POSIX path of (target of the front window as alias))
on error
set currentFolder to desktop
set currentPath to (POSIX path of (desktop as alias))
end try
end tell
tell application "Terminal"
activate
delay 0.5
tell application "System Events"
set cdtocurrentPath to "cd \"" & currentPath & "\"" as string
keystroke cdtocurrentPath
keystroke return
end tell
end tell
以前,在 OS X 10.9 中,输入当前路径的击键速度非常快(长字符串不到 1 秒)。但是,在 10.10 中,它往往非常慢(通常超过 3-4 秒),因此我可以清楚地看到正在输入的字母。
此外,其他动作System Events
也比 10.9 慢,因此我必须增加时间delay
才能使它们正常工作。
谁能解释一下?或者给出一个替代解决方案?谢谢!