Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can AppleScript listen for events?

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?

like image 444
kch Avatar asked Jun 27 '10 11:06

kch


1 Answers

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

like image 169
mcgrailm Avatar answered Sep 28 '22 06:09

mcgrailm