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: "francois.houle" <email@hidden>
- Date: Thu, 09 Jun 2005 15:30:47 -0400
I could not get the idle handler script to work... Or it actually goes
through and exits immediately wether the return statement for the "tst"
variable is true or not... Here is what I am trying.. I also tried the
original that you sent with no more success
on idle
tell application "System Events" to set tst to (name of every process
contains "Installer")
if tst is true then
return 2 -- number of seconds to idle
else if tst is false then
display dialog "Closed !" buttons {"Ok"}
tell me to quit
end if
end idle
Have any idea what I'm missing here ?
On 6/9/05 4:56 AM, "J. Stewart" <email@hidden> wrote:
> 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
_______________________________________________
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