Re: so what's going on here?
Re: so what's going on here?
- Subject: Re: so what's going on here?
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 20 Feb 2007 09:52:04 -0800
- Thread-topic: so what's going on here?
Title: Re: so what's going on here?
On 2/20/07 2:58 AM, "Bill Briggs" <email@hidden> wrote:
At 6:38 PM -0800 2/19/07, Paul Berkowitz wrote:
On 2/19/07 6:23 PM, "Bill Briggs" <email@hidden> wrote:
And it gets more strange. If you exclude System Events specifically by filtering to get application processes whose background only is false (and System Events has a background only that is true), then Script Editor pops up as the frontmost application, no matter what application is frontmost.
What exactly was your code for that test? I can't replicate that.
tell application "System Events"
set testList to the name of every application process whose background only is false
-- the above line filters out System Events
repeat with i from 1 to count of testList
set apName to (get item i of testList)
if frontmost of application process apName is true then
set fMost to apName
else
end if
end repeat
end tell
display dialog fMost
This tells me Script Editor is the frontmost application when, for example, Eudora is frontmost. But only from the Scripts menu. Not from TypeIt4Me or FastScripts. FastScripts gets it right, whether it's iCal, Eudora, whatever.
This appears to be a different issue. I think if you open the script, recompile it, and save it, then run it from the script menu, you will get no display dialog at all. That is because none of the processes in testList have their frontmost true (since System Events is frontmost and it has been excluded from testList), so fMost is undefined. It should error 'The variable fMost is undefined' but instead just quits. (That's a bug. You can test this by inserting any undefined variable and then calling a valid display dialog, such as
set x to y
display dialog "Hi"
instead of the last line of the script, and running it from the script menu. You never see any display dialog.)
The reason why you saw Script Editor returned is that you must have run the script in Script Editor first, then saved it without recompiling, That saves all top-level variables, including apName and fMost, as implicit globals. (Matt Neuburg is very good on this issue in his book.) So, when the script runs from the script menu, since testList is in fact {}, fMost never gets reset and is still "Script Editor" as previously saved. I was able to reproduce this doing the same thing with Script Debugger.
Recompiling the script, saving and then running from the script menu showed no display dialog, thus no frontmost process among those whose background only is true, since the so-called frontmost process as recognized by System Events when running a script from the Script menu, is System Events itself, the 'current application' running the script menu.
Just use 'path to frontmost application' instead until these bugs are fixed.
--
Paul Berkowitz
_______________________________________________
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/mailman//archives/applescript-users
This email sent to email@hidden