Re: detect launch of file?
Re: detect launch of file?
- Subject: Re: detect launch of file?
- From: Ken Dobson <email@hidden>
- Date: Tue, 13 Mar 2001 19:17:59 -0500
on 3/13/01 6:37 AM, email@hidden at
email@hidden wrote:
>
> From: Sander Tekelenburg <email@hidden>
>
> Date: Tue, 13 Mar 2001 08:52:18 +0100
>
> To: email@hidden
>
> Subject: Re: detect launch of file?
>
>
>
> -----BEGIN PGP SIGNED MESSAGE-----
>
> Hash: SHA1
>
>
>
> At 09:45 -0800 UTC, on 12/03/2001, Phil Calvert wrote:
>
>
>
>> Is there any way (via applescript) to detected the launch of a file? I want
>
>> an applescript to do something only if a certain file type is launched.
>
>
>
> I wouldn't know, but I doubt it. However, it _is_ possible to ask the Finder
>
> whether or not an application is running[*]. If by "file type" you don't mean
>
> it in the general sense, but a file that is specific to an application, then
>
> perhaps this is a viable route to take. (Because opening a file would
>
> activate the application).
>
>
>
> This would mean having to use a stay-open applet that uses an "on idle"
>
> handler so it will continuously checks for changes.
>
>
>
>
>
> [*]
>
> tell app "Finder"
>
> get processes
>
> end
>
>
>
>
If you are looking to do something once a specific file is opened, you could
try stretching out the suggested idle handlers like this ( been running in
the background here for about an hour...)
------
property appName : "AppleWorks"
property Filename : "Domo"
on idle
tell application "Finder" to set AppList to name of processes
if AppList contains appName then
try
tell application appName to set FileList to name of windows
if FileList contains Filename then
beep 2 (*do your thing*)
end if
on error
return 10
end try
end if
return 10
end idle
------