Using event handlers, you can develop AppleScripts that are capable of reacting to predefined events, like script startup and termination. AppleScript supports a number of different event handlers, including those listed here:
run. Automatically executes whenever the AppleScript is run.
open. Automatically runs whenever a file, folder, or disk is dragged and dropped onto an AppleScript file.
idle. Automatically runs on a periodic basis whenever an AppleScript enters an idle state.
quit. Automatically runs when an AppleScript receives a Quit command.
reopen. Automatically runs when a docked AppleScript application is reactivated.
Note that when you work with event handlers, you do not include a pair of parentheses ...