Re: System Idle Time ... again ...
Re: System Idle Time ... again ...
- Subject: Re: System Idle Time ... again ...
- From: Mike Paquette <email@hidden>
- Date: Fri, 29 Apr 2005 17:06:28 -0700
On Apr 26, 2005, at 1:43 AM, Mike Lewis wrote:
I also tried to use CGSSecondsSinceLastInputEvent, as pointed out
by Evan, but it gives me linker error: "undefined symbols
CGSSecondsSinceLastInputEvent". I inserted the prototype and tried
to link ApplicationServices framework but still can't get rid of
this error. Is there something obvious I'm missing?
That's not a public interface...
As I understand this is an undocumented function, so can somebody
from Apple tell us, what is the official way of getting system idle
time on Tiger?
#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