Event to stop the screensaver.

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

  1. DeDMakar macrumors member

    Mar 24, 2008
    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. DeDMakar thread starter macrumors member

    Mar 24, 2008
    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. kainjow Moderator emeritus


    Jun 15, 2000
    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. DeDMakar thread starter macrumors member

    Mar 24, 2008

Share This Page