Running Chris’s script under Yosemite also gives me the wrong results. It works fine, as he stated, under Mavericks.
To be clear: I’m running these from a script saved as an application. For my use, that is crucial as I have many applets which end with “tell me to activate” and then immediately display a dialog. In Yosemite, the applet is not brought forward, and I get the bouncing dock icon.
Those of you getting the name of an editor are obviously running from an editor. It is interesting to see that some scripts are failing from there as well. We all know using delay is a method of last resort, and in this case it appears to be even less reliable.
For now, I will need to use System Events combined with Shane’s AS/ObjC to make activate work like it should—activate the application, and then wait until it is in front before proceeding with any other commands. For Yosemite users only, of course. I’ve posted the complete test below just FYI. You could put the “path to” and posix coercion in the subroutine, but you would need to add a condition to handle “path to me”.
Jörgen asked…
What do you guess: Will Apple do something about it quite soon?
I’m only guessing. But I would agree with Shane’s guess that this is likely a change to the underlying behavior system-wide. As such, we could be waiting a long time on a fix. Let’s hope not. I have filed a feedback report, and will leave a bug report as well for good measure.
Ray Robertson
--------- use scripting additions use framework "Foundation"
set appNameReportText to "" tell application "Finder" my activateAppAtPath:(POSIX path of (path to application "Finder")) set thisAppName to my getFrontmostAppName() end tell set appNameReportText to appNameReportText & thisAppName & return
tell application "Mail" my activateAppAtPath:(POSIX path of (path to application "Mail")) set thisAppName to my getFrontmostAppName() end tell set appNameReportText to appNameReportText & thisAppName & return
my activateAppAtPath:(POSIX path of (path to me)) set thisAppName to my getFrontmostAppName() set appNameReportText to appNameReportText & thisAppName & return tell me to activate tell current application display dialog appNameReportText end tell
on getFrontmostAppName() tell application "System Events" set frontmostName to item 1 of (get name of processes whose frontmost is true) end tell return frontmostName end getFrontmostAppName
on activateAppAtPath:appPosixPath set theNSBundle to current application's NSBundle's bundleWithPath:appPosixPath set processName to (theNSBundle's objectForInfoDictionaryKey:"CFBundleName") as text tell application "System Events" to tell process processName set frontmost to true end tell end activateAppAtPath:
|