0

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 秒以上)、入力されている文字をはっきりと見ることができます。

さらに、 の他のアクションも 10.9 よりも遅いため、それらを適切に機能させるにSystem Eventsは時間を増やす必要があります。delay

誰かがこれを説明できますか?または代替ソリューションを提供しますか?ありがとう!

4

1 に答える 1

0

10.10 の Script Editor でテストしたところ、1 秒未満で実行されました。他に何か問題があるはずです。

do script次のコマンドを使用すると役立つ場合があります。

tell application "Terminal" to do script "cd \"" & currentPath & "\""
于 2014-10-26T00:47:43.740 に答える