Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



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: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.