• 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
Re: Yosemite and activate failures
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Yosemite and activate failures


  • Subject: Re: Yosemite and activate failures
  • From: "Stockly, Ed" <email@hidden>
  • Date: Fri, 16 Jan 2015 00:12:18 +0000
  • Thread-topic: Yosemite and activate failures

I toyed around with it and came up with this demo.  I get very different,
but consistent results depending on which delay in this script I note out.

So what¹s happening is that an app activates and the script sends the next
command to system events before system events gets the notification that
an application process's frontmost property has changed.That would explain
the inconsistent results and why delay helps.

Probably worth filing a bug report.


_______
tell application "System Events"
	set applicationList to the name of every application process whose has
scripting terminology is true
end tell
set appNameReportText to ""
repeat with thisApplication in applicationList
	try
		tell application thisApplication
			activate
			--delay 1
			set thisAppName to my getFrontmostAppName()
		end tell
	end try
	set appNameReportText to appNameReportText & thisApplication & "--" &
thisAppName & return

end repeat
tell me to activate
display dialog appNameReportText

on getFrontmostAppName()
	tell application "System Events"

		set frontmostName to item 1 of (get displayed name of application
processes whose frontmost is true)
		--delay 1
		set frontmostName to frontmostName & space & "-" & space & item 1 of
(get name of processes whose frontmost is true)
	end tell
	return frontmostName
end getFrontmostAppName
___________



On 1/15/15, 3:22 PM, "Deivy Petrescu" <email@hidden> wrote:

>
>> On Jan 15, 2015, at 16:15 , Ray Robertson <email@hidden>
>>wrote:
>>
>> On Jan 15, 2015, at 3:06 PM, Yvan KOENIG <email@hidden> wrote:
>>
>>> What I described as the correct result is in fact :
>>> <snip>
>>> So, It's not the normal one.
>>
>> Thanks for testing. I should add: I¹m often getting different results
>>when running the original script with the ³activate² command. I¹ve yet
>>to see a pattern behind the behavior. I just know in almost all cases
>>the result is wrong.
>>
>>> My understanding is that as it has so graphical interface, the
>>>script's process is not seen as the frontmost one.
>>
>> I have not heard that anything app without a GUI would not be seen as
>>frontmost. Regardless, it seems as if System Events is able to ensure an
>>application is frontmost. But under Yosemite we can no longer rely upon
>>³activate² in applets. Anyone using GUI scripting in an applet should
>>take note, though this will also affect some scripts using pure
>>AppleScript as well.
>>
>> Ray
>> _______________________________________________
>
>Ray, it is working as expected, it is just running faster (or slower)
>than before (if it used to work).
>Try this script and you will see that it is running correctly
>
><script>
>set appNameReportText to ""
>tell application "Finder" to activate
>say "a"
>set appNameReportText to appNameReportText & getFrontmostAppName() &
>return
>
>tell application "Mail" to activate
>say "b"
>set appNameReportText to appNameReportText & getFrontmostAppName() &
>return
>
>tell current application to activate
>say "c"
>set appNameReportText to appNameReportText & getFrontmostAppName() &
>return
>
>display dialog appNameReportText
>
>on getFrontmostAppName()
>	tell application "System Events" to return item 1 of (get name of
>processes whose frontmost is true)
>end getFrontmostAppName
></script>
>
>Now, what Yvan said was not normal it is in fact normal, run the
>following script:
>
><script>
>set appNameReportText to ""
>tell application "Finder" to activate
>set appNameReportText to appNameReportText & getFrontmostAppName() &
>return
>say "a"
>
>tell application "Mail" to activate
>set appNameReportText to appNameReportText & getFrontmostAppName() &
>return
>say "b"
>
>tell current application to activate
>set appNameReportText to appNameReportText & getFrontmostAppName() &
>return
>say "c"
>
>display dialog appNameReportText
>
>on getFrontmostAppName()
>	tell application "System Events" to return item 1 of (get name of
>processes whose frontmost is true)
>end getFrontmostAppName
></script>
>
>The difference is that the first application that is front most when you
>click run script is Script Editor.
>so, the test to do is run this script timing every step both in Mavericks
>and Yosemite and see the difference.
>
>
>Deivy Petrescu
>email@hidden
>
>
>
>
> _______________________________________________
>Do not post admin requests to the list. They will be ignored.
>AppleScript-Users mailing list      (email@hidden)
>Help/Unsubscribe/Update your Subscription:
>imes.com
>Archives: http://lists.apple.com/archives/applescript-users
>
>This email sent to email@hidden



 _______________________________________________
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


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: Yosemite and activate failures (From: Deivy Petrescu <email@hidden>)

  • Prev by Date: Re: Yosemite and activate failures
  • Next by Date: Re: Yosemite and activate failures
  • Previous by thread: Re: Yosemite and activate failures
  • Next by thread: Re: Yosemite and activate failures
  • Index(es):
    • Date
    • Thread