Re: two questions
Re: two questions
- Subject: Re: two questions
- From: Steven Angier <email@hidden>
- Date: Wed, 16 Jan 2002 08:54:00 +1100
- Organization: Macscript.com
This sort of thing is made simple by using our Macscript.com Library. A demo is available
from our site: <
http://www.macscript.com>.
With it you could write something like:
----
property kCreatorType : "ttxt" --the creator type of your target app
on run
--adjust the sound volume (0 = off; 7 = highest)
set volume 7
--then, launch the target app
ActivateApp(kCreatorType)
--wait until the app is finished launching
repeat until IsProcessRunning(kCreatorType)
--just wait
end repeat
end run
on idle
--see if the target app is still running
if not IsProcessRunning(kCreatorType) then
--mute the sound
set volume 0
--quit this app
quit
end if
--otherwise, check again in 1 second
return 1
end idle
----
Change the creator type at the top of the script and save it as a stay open application
(with the Macscript.com Library attached). This should do what you want.
>
Also, I've read that repeat commands should be avoided, that I
>
should use on-idle commands instead. Is this true, or is it just something
>
that used to be good practice back when machines weren't as fast as they
>
are now? Thanks in advance.
Yes, generally idle commands are more polite and don't hog too many system resources, but
both are appropriate in different situations. The above script uses both repeat loop and
idle handler techniques.
Hope this helps,
Steven Angier
Macscript.com
References: | |
| >two questions (From: "Ricardo J. Seijo" <email@hidden>) |