Testing if app running before sending AppleScript
Testing if app running before sending AppleScript
- Subject: Testing if app running before sending AppleScript
- From: Greg Hurrell <email@hidden>
- Date: Tue, 21 Jan 2003 16:48:10 +1030
Hi all,
I want to test if Mail.app is running before sending it an AppleScript.
The problem is, if I quit Mail.app just before doing the test, then my
program thinks Mail.app is still running and so it sends the
AppleScript which has the undesired side effect of relaunching the app!
Evidently, the test is failing.
I have tried two ways of doing it:
1. Using NSWorkspace and launchedApplications to find out if Mail.app
is running.
2. Using the Carbon Process Manager and "GetNextProcess"
Neither of these seem to be 'quick' enough. In other words, I quit
Mail, and it hangs around in the list of running processes for a while
before these things "notice" that it's gone.
My initial attempt (using only AppleScript) failed also:
>
tell application "Finder"
>
if (get name of every process) contains "Mail" then
>
tell application "Mail"
[etc...]
It appears there is a slight delay between quitting Mail.app the Finder
knowing that Mail has quit.
Any advice? All I really want to know is: Is the app running and ready
to receive AppleScript? I explicitly want to avoid the situation where
it's quitting or just been quit, and so sending an AppleScript is not
the desired thing.
Cheers
Greg
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.