Frontmost Application Problem
Frontmost Application Problem
- Subject: Frontmost Application Problem
- From: Luther Fuller <email@hidden>
- Date: Wed, 23 Apr 2008 15:55:00 -0500
This is a follow-up to Jim Krenz's question "Script to launch or
toggle the visibility of an application?"
In one of my script's I replaced, this morning, the line ...
short name of (info for (path to frontmost application)) as text
with the line ...
tell application "System Events" to (name of (some process whose
frontmost is true)) as text
This code is in a script which is compiled as a faceless background
application bundle, so it never appears in the menu bar or dock.
While testing, I was surprised to find that my application no longer
behaved properly.
It took some hours to find the well hidden problem. The first line
always returns, correctly, the name of the application which appears
at the left of the menu bar. The second line, under the right
conditions, will return the name of my application. But this isn't
supposed to happen, since my application is an FBA and its name never
appears in the menu bar.
The problem occurred because, under the right conditions, a handler
which runs before line 2 executes the command 'activate me'. (This
command, fortunately, didn't do anything useful, so I simply removed
it. Now my application is working properly.)
The 'activate me' command does not cause my application to appear in
the menu bar or dock, so line 2 should NOT return the name of my
application ... but it does. If you use this in a script compiled to
an FBA, you should make it the first line, something like this ...
tell application "System Events" to set currentAppl to (name of
(some process whose frontmost is true)) as text
I haven't the slightest idea if there is a bug here. Perhaps someone
knows.
_______________________________________________
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