Re: Problem setting a script to check for a running app
Re: Problem setting a script to check for a running app
- Subject: Re: Problem setting a script to check for a running app
- From: "J. Stewart" <email@hidden>
- Date: Thu, 9 Jun 2005 04:56:29 -0400
On 06/08/05 at -0400 francois.houle said this
>I'm trying to setup as script so it it remains idle in the background until
>a specific process ends (and thus disappears form the process list)
>Here is what I have for now but I can't figure out why its not working:
>
>tell application "System Events"
> set proc_list to every process
> repeat until proc_list does not contain "Installer"
> if proc_list contains "Installer" then
> quit (delay 0)
> else if proc_list does not contain "Installer" then
> exit repeat
> end if
> end repeat
>end tell
>
>Basically I want the script to check continuously to see if the process is
>runnign and only exit it once it doesn't run anymore, and only run the rest
>of the script once the loop has been exited...
>I've tried many variations but can never get it to work properly...
I'd suggest not using a repeat loop in this manner because it can use too many processor cycles and make it look like your system is hung.
A stay-open application script with an "idle" handler something like this should do what you want.
on idle
tell application "System Events" to set tst to (name of every process contains "Installer")
if tst then
return 2 -- number of seconds to idle
else
-- do rest of code here
tell me to quit
end if
end idle
This checks once every 2 seconds to see if a process named "Installer" is running, if it is then it "idles" for another 2 seconds. When the "Installer" process ceases to operate then the script will perform the "else" portion of the "if-else" test and then quit itself.
JBS
--
The older we get, the fewer things seem worth waiting in line for.. — Will Rogers
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden