I am using applescript on Mac OS X 10.10 (Yosemite). I notice that the keystroke action tends to be much slower than 10.9.
Below is my applescript, which tells Terminal to input "cd my current path in Finder
" and press 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
Previously, in OS X 10.9, the keystroke for inputting the current path is very fast (less than 1s for a long string). However, in 10.10, it tends to be very slow (usually more than 3-4s) such that I can clearly watching the letters being typed.
Besides, other actions in System Events
are also slower than 10.9 and hence I have to increase the time for delay
to make them work properly.
Could anyone possibly explain this? Or give an alternative solution? Thanks!