• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Yosemite and activate failures
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Yosemite and activate failures


  • Subject: Yosemite and activate failures
  • From: Ray Robertson <email@hidden>
  • Date: Thu, 15 Jan 2015 13:33:02 -0500
  • Sun-java-system-smtp-warning: Lines longer than SMTP allows found and truncated.

When using “activate” in an applet, I’m getting unreliable results under 10.10.1. I’m using the script below to test, which should display the name of each application which was activated…

----------------
set appNameReportText to ""
tell application "Finder"
activate
set thisAppName to my getFrontmostAppName()
end tell
set appNameReportText to appNameReportText & thisAppName & return

tell application "Mail"
activate
set thisAppName to my getFrontmostAppName()
end tell
set appNameReportText to appNameReportText & thisAppName & return

tell me to activate
tell current application
activate
set thisAppName to my getFrontmostAppName()
set appNameReportText to appNameReportText & thisAppName & return
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
----------------

Yes, there is some redundancy with “activate" at the end, but I’m trying to activate the script app itself before displaying the final dialog.

When saving the above as an application, if I run it in Mavericks I reliably get what is expected. The dialog reports…

Finder
Mail
<name of applet>

The script ends with the applet itself frontmost and the dialog displaying properly.

Running the same thing in Yosemite reports inconsistent results: sometimes “Finder Finder Finder” or the name of the applet repeated three times. And before anyone thinks Mail could be causing the problem (a worthy suspicion) this still happens when addressing other applications.

Adding delays helps *some* in actually bringing other apps frontmost, but still does not work reliably. And regardless of whether there are delays, I alway get the bouncing dock icon at the end and have to click that to bring the applet to the front and see the dialog.

I asked another developer running the latest developer preview to test the above. No luck—he got the same behavior.

After reading some previous messages here, I’ve resorted to activating applications via System Events as a workaround…

----------------
set appNameReportText to ""
set scriptAppName to name of me

my activateApp("Finder")
set thisAppName to my getFrontmostAppName()
set appNameReportText to appNameReportText & thisAppName & return

my activateApp("Mail")
set thisAppName to my getFrontmostAppName()
set appNameReportText to appNameReportText & thisAppName & return

my activateApp(scriptAppName)
set thisAppName to my getFrontmostAppName()
set appNameReportText to appNameReportText & thisAppName & return
tell current application
display dialog appNameReportText
end tell

on activateApp(appName)
tell application "System Events" to tell process appName
set frontmost to true
end tell
end activateApp

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
----------------

So far, the above appears to work reliably. Obviously, abandoning the activate command altogether is not desirable.

I’d appreciate anyone else verifying the same results in script applications under Yosemite. Other approaches for getting around this issue are certainly welcome.

Ray Robertson
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Yosemite and activate failures
      • From: Christopher Stone <email@hidden>
    • Re: Yosemite and activate failures
      • From: Shane Stanley <email@hidden>
    • Re: Yosemite and activate failures
      • From: Yvan KOENIG <email@hidden>
References: 
 >Script that "Tells" Finder just Focuses on Finder instead of running (From: Alex Hall <email@hidden>)
 >Re: Script that "Tells" Finder just Focuses on Finder instead of running (From: Deivy Petrescu <email@hidden>)
 >Re: Script that "Tells" Finder just Focuses on Finder instead of running (From: 2551 <email@hidden>)
 >Re: Script that "Tells" Finder just Focuses on Finder instead of running (From: Alex Hall <email@hidden>)
 >Re: Script that "Tells" Finder just Focuses on Finder instead of running (From: Deivy Petrescu <email@hidden>)
 >Re: Script that "Tells" Finder just Focuses on Finder instead of running (From: Shane Stanley <email@hidden>)
 >Re: Script that "Tells" Finder just Focuses on Finder instead of running (From: Deivy Petrescu <email@hidden>)
 >Re: Script that "Tells" Finder just Focuses on Finder instead of running (From: Shane Stanley <email@hidden>)
 >Re: Script that "Tells" Finder just Focuses on Finder instead of running (From: Deivy Petrescu <email@hidden>)
 >Re: Script that "Tells" Finder just Focuses on Finder instead of running (From: Shane Stanley <email@hidden>)
 >Re: Script that "Tells" Finder just Focuses on Finder instead of running (From: Shane Stanley <email@hidden>)
 >Re: Script that "Tells" Finder just Focuses on Finder instead of running (From: Yvan KOENIG <email@hidden>)
 >Re: Script that "Tells" Finder just Focuses on Finder instead of running (From: Shane Stanley <email@hidden>)
 >Re: Script that "Tells" Finder just Focuses on Finder instead of running (From: Yvan KOENIG <email@hidden>)
 >Re: Script that "Tells" Finder just Focuses on Finder instead of running (From: Shane Stanley <email@hidden>)
 >Re: Script that "Tells" Finder just Focuses on Finder instead of running (From: Alex Hall <email@hidden>)
 >Re: Script that "Tells" Finder just Focuses on Finder instead of running (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Launch agent issue
  • Next by Date: Re: Launch agent issue
  • Previous by thread: Re: Script that "Tells" Finder just Focuses on Finder instead of running
  • Next by thread: Re: Yosemite and activate failures
  • Index(es):
    • Date
    • Thread