PDA

View Full Version : Event to stop the screensaver.




DeDMakar
Apr 9, 2008, 02:53 AM
Hi,
Is there a way that my application can immediately start to work when will stop screensaver.
Is there an Event or Notification or something like that I could use?
I need to define that moment when it is necessary to enter the passport and user.



DeDMakar
Apr 9, 2008, 04:03 AM
I found:
* com.apple.screensaver.action (with userinfo {action=1})
* com.apple.screensaver.didstart (no userinfo)
* com.apple.screensaver.willstop (no userinfo)
* com.apple.screensaver.didstop (no userinfo)

URL: http://www.cocoadev.com/index.pl?IsScreenSaverRunning
How to use them correctly?:(

kainjow
Apr 9, 2008, 05:51 AM
Assuming those notifications are correct and they're still being sent in Leopard (can't test right now), you would need to do this:

- (id)init {
self = [super init];
[[NSDistributedNotificationCenter defaultCenter] addObserver:self
selector:@selector(screenSaverDidStop:)
name:@"com.apple.screensaver.didstop" object:nil];
return self;
}

- (void)screenSaverDidStop:(NSNotification *)notification {
// do something here
}

Edit: if you're not using Cocoa you can use CFNotificationCenterGetDistributedCenter() and related functions instead.

DeDMakar
Apr 11, 2008, 07:39 AM
Thanks!!!:D