• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Detect System Idle?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detect System Idle?


  • Subject: Re: Detect System Idle?
  • From: Fabio Mancinelli <email@hidden>
  • Date: Wed, 11 Apr 2007 15:36:10 +0200


On Apr 11, 2007, at 3:00 PM, Andrew James wrote:

Hi,

Is there a method to hook into the system to detect when the system has been idle for a certain period of time, not just the application its self but the whole system.

Like i want to run a method when the system has been idle for n minutes

There is a "private" API called CGSSecondsSinceLastInputEvent that returns the number of seconds since the last input has been received. I use this in a small utility that I have developed and it works under Tiger (10.4.{6,7,8,9}).

Being a private API you should be aware of the fact that your application could be incompatible with other OS X versions (past and future).

The prototype is: double CGSSecondsSinceLastInputEvent(long evType);
CGSSecondsSinceLastInputEvent(-1) would do the trick.

Hope this helps.

See you,
Fabio

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Detect System Idle? (From: Andrew James <email@hidden>)

  • Prev by Date: Re: Detect System Idle?
  • Next by Date: Drawing to NSImage to create image data at different resolutions
  • Previous by thread: Re: Detect System Idle?
  • Next by thread: Drawing to NSImage to create image data at different resolutions
  • Index(es):
    • Date
    • Thread