• 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: System Idle Time ... again ...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: System Idle Time ... again ...


  • Subject: Re: System Idle Time ... again ...
  • From: Dan Messing <email@hidden>
  • Date: Sat, 30 Apr 2005 19:34:02 -0500

Is there a solution that will also work for pre-Tiger applications?

Dan


On Apr 29, 2005, at 10:18 PM, Mike Paquette wrote:

#include <ApplicationServices/ApplicationServices.h>


/*
* Time since last event for an event source.
*
* The kCGAnyInputEventType eventType will report the last timestamp
for any
* input event, keyboard, mouse, or tablet. The various system and app
* defined events do not contribute to this event type's time.
*
* Again, a program or application posting from within a login
session should use
* the kCGEventSourceStateCombinedSessionState.
*
* A user space device driver interpreting hardware state and
generating events
* should use the kCGEventSourceStateHIDSystemState.
*/


CG_EXTERN CFTimeInterval CGEventSourceSecondsSinceLastEventType
( CGEventSourceStateID source, CGEventType eventType )
AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;


Make sure you include that header above. Without the prototype, the compiler will assume an integer return, which will have your code reading the wrong register!

To determine how long it's been since your user's session received
any input from keyboard or mouse:

     CFTimeInterval timeSinceLastEvent;

     timeSinceLastEvent  = CGEventSourceSecondsSinceLastEventType
(kCGEventSourceStateCombinedSessionState, kCGAnyInputEventType);


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Prev by Date: Re: Cocoa Technologies Back-Story?
  • Next by Date: Dictionary lookups for non-NSTextView clients?
  • Previous by thread: Re: System Idle Time ... again ...
  • Next by thread: Workaround for ABPeoplePickerValueSelectionDidChangeNotification bug?
  • Index(es):
    • Date
    • Thread