1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Event to stop the screensaver.

Discussion in 'Mac Programming' started by DeDMakar, Apr 9, 2008.

  1. macrumors member

    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.
  2. macrumors member

    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?:(
  3. Moderator emeritus


    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
            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.
  4. macrumors member


Share This Page