views:

86

answers:

1

I want to write a script that takes action when a document is opened on a certain application, or before an application quits, etc.

Is there a way to attach a script to an event in an application? Does AppleScript support any form of hooks at all?

If not, can I hack my way into getting what I want?

+2  A: 

applescript only has certain "event listeners" the are folder action script that might be considered an event listener and indesign has real event listeners which I won't get into at the moment.

if you want a blanket listener for any application to quit you may find what your looking for in a Quickeys though I'm not certain of this as it has been a long time since I have messed around with quickeys.

but all and all the answer is for the most part no.

hth Mike

EDIT more tools that may help brought by kch

FastScripts

QuickSilver

Keyboard Maestro

"Some apps, eg. iChat, have script hooks in the preferences. In iChat, the Alerts preference pane, you can set it to run a script when a certain event is triggered, like message received, file transfer request, etc." – kch

mcgrailm
Add to the list of tools that more or less help with this: FastScripts, Quicksilver, Keyboard Maestro.
kch
Some apps, eg. iChat, have script hooks in the preferences. In iChat, the Alerts preference pane, you can set it to run a script when a certain event is triggered, like message received, file transfer request, etc.
kch
Ok I'll go ahead and accept your answer. It would be nice if you incorporated my comments in it for completion.
kch
@kch I edited my post to reflect your comments
mcgrailm