On Aug 30, 2009, at 6:06 PM, Deivy Petrescu wrote:
tell application "Finder"
beep 2
--> error number -10004
end tell
tell current application
beep 2
end tell
This will happen in many instances.
Even if there is an error trap, this would not prevent it from beeping.
That is, this beeps.
tell application "Finder"
try
beep 2
on error e
say e
end try
end tell
For security reasons, in Snow Leopard most of the standard scripting additions no longer accept Apple events from other processes (or other machines); instead, the addition event handler returns a “privilege violation” error (-10004).
For compatibility with existing scripts, when AppleScript receives this error, in most cases it redirects the event to the current process to handle instead. This redirection occurs automatically, so the intermediate -10004 error isn’t seen by the script and won’t be caught by “try/on error,” although all the events and replies are logged.
Note that if you send a command to another computer via EPPC, if the addition must be run on the target computer, it may be redirected to System Events on that machine instead of to the current process. For example, “beep” must be handled on the target machine, because you obviously want the sound to play there rather than on the machine running the script.
See the Snow Leopard release notes for AppleScript for more details:
In most cases, this redirection shouldn’t cause any real change to your script behavior, although your script may run slower because of the additional events being sent. We encourage you explicitly send scripting addition commands to the current application, either by prefixing them with “tell me to …” or “my” (when applicable), or by moving them outside of tell blocks.