On Jun 25, 2009, at 12:18 PM, Steve Mills wrote:
On Jun 25, 2009, at 14:05:25, Deivy Petrescu wrote:
"sleep" is an System Events event.
It's also a Finder event in the Legacy suite.
On Jun 25, 2009, at 9:44 AM, Deivy Petrescu wrote: Actually, using the Finder and the bonjour name of the Mac works fine here. System Events does not!
Interesting, because few OS's ago (I really can't remember which OS!), System Events was the way to go for remote scripting. Now it will not work. It complains that the app is not running. May be this was brought upon us by security reasons. Both Chris's can elaborate on that
Here’s the scoop:
• “sleep” and some other events were originally handled by Finder. Now they are handled by System Events.
• If you send one of these events to Finder, it returns an error that tells AppleScript to send the event to System Events instead. If you run the script in Script Editor and look at the event log, you should see this sequence of events.
• Unlike local events, when you send an event to a remote machine, it will not automatically launch applications that aren’t running. They must already be open, or you must explicitly tell Finder to open them. System Events is not always running, so you may need to have your script explicitly tell Finder to open it when it isn’t already open, if you can’t arrange for it to always be open on the target machine.
• When you send an event to Finder on a remote machine and it is redirected by AppleScript to System Events, AppleScript automatically tells Finder to open System Events if it isn’t already open, then attempts to send the event to System Events again. Script Editor’s event log will contain a series of events reflecting this.
If this isn’t working for you, please reproduce the problem in a short script and post the script and the event log here.
Note that the details of these behaviors changed over time, and you indicated that you’re working with two different Mac OS X versions, so this automatic behavior may not work for your situation and you may need to arrange for System Events to be open, as I mentioned above.
-- Chris Page
The other, other AppleScript Chris
|