On 4/27/02 2:48 PM, "Mr Tea" <[EMAIL PROTECTED]> wrote:

> I'm using a stay-open AppleScript applet that tells me about new mail when
> Entourage X is running in the background. That's the idea, anyway.
> 
> The script tests whether or not Entourage is frontmost by asking the Finder
> to get the creator type of the frontmost process and - in theory - only
> doing its stuff if the result is not "OPIM". Often, however, it ignores this
> stipulation for no obvious reason - like just now while I'm typing this
> message.
> 
> Why? Is Entourage not always frontmost when it appears to be so? I wondered
> if Microsoft, in its cheeky, loveable way, was slipping additional processes
> into the mix, and found the 'Microsoft Database Daemon' lurking hard by. But
> I can't find any evidence that suggests it's muscling its way to the front
> and confusing my applet.
> 
> Maybe it's just me that's confused. I've appended the relevant part of the
> applet - perhaps someone can suggest a more robust way of checking whether
> or not Entourage is frontmost, or even just a way that works.
> 
> 
> tell application "Finder" to set activeApp to creator type of (every
> application process whose frontmost is true)
> 
> if activeApp is not "OPIM" then my AnnounceMail()

Hi, Mr. Tea (Nick). It's nothing to do with Entourage, nor the Database
Daemon.

There are a lot of faceless apps in OS X, doing their stuff. it's possible
that they may even be in front some of the time. For example, if you happen
to be running this script from the OS's Script menu, the SystemUIServer is
in front. 

But it's not just that. I think the Finder is probably buggy here. On top of
which you actually have a syntax error. it should be:

tell application "Finder" to set activeApp to creator type of (every
application process whose frontmost is true) -- that's a list

if activeApp is not "OPIM" then my AnnounceMail()  -- wrong

    if activeApp is not {"OPIM"} then my AnnounceMail() -- correct

OR

if item 1 of activeApp is not "OPIM" then my AnnounceMail()

Now by rights, you should be able to do this instead:

    tell application "Finder" to set activeApp to creator type of (first
application process whose frontmost is true)

But, in fact, in OS 10.1x, that turn out to be the same list as (every).
that's a bug, so who knows how many other bugs there may be?

I would forget 'application process' and instead just use 'process', if I
were you:

    tell application "Finder" to set activeApp to creator type of (every
process whose frontmost is true)

just in case some non-application faceless process is in front. Were that to
be the case, the Finder would probably not error loudly but just pass by,
which is what you say it's doing.

In fact, I might not use the Finder at all:

    set activeApp to path to frontmost application -- an alias

    set activeAppType to file creator of (info for activeApp)

OR

    tell app "Finder" to set activeAppType to creator type of activeApp

BTW, Entourage will never have any other name than "Microsoft Entourage" -
there will never be a version number or anything like that. So you don't
really have to bother with "OPIM".



-- 
Paul Berkowitz


-- 
To unsubscribe:                     
<mailto:[EMAIL PROTECTED]>
archives:       
<http://www.mail-archive.com/entourage-talk%40lists.letterrip.com/>
old-archive:       
<http://www.mail-archive.com/entourage-talk%40lists.boingo.com/>

Reply via email to