If your are application needs to know if the Mac has gone to sleep (or
more
specifically, when the Mac wakes up from sleep) you can get this
information
very easily. It turns out that the Mac OS sends a "wake" AppleEvent to
all
applications when the Mac wakes up from sleep.
You will need to add a class based on Application (if you don't already
have
one) to your project.
The HandleAppleEvent event handler of the Application class fires
anytime
your application receives an AppleEvent. This event handler is passed
the
AppleEvent, the eventClass and the eventID. To determine that you have
received the wake event, in the HandleAppleEvent event handler, check
to see
if the eventClass is "pmgt" and the eventID is "wake". Should you
receive an
AppleEvent with these values, the Mac has just woke up from sleep.
Keep in mind that AppleEvent classes and ids are case sensitive. Also,
you
won't receive these events when running your application in the IDE. You
will only receive them in your built applications.
--
Geoff Perlman
President & CEO
REAL Software, Inc.
http://www.realsoftware.com
mailto:geoff at realsoftware dot com
Phone: 512-263-1233 x711
Fax: 512-263-1441
- - - - - - - - - -
Got a useful tip to share? Send it to us at:
REALbasic-tips at lists dot realsoftware dot com dot
For list commands, send "Help" in the body of a message to
<requests at lists dot realsoftware dot com>
|