Detecting inactivity of the user

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Detecting inactivity of the user

Bill Schwab-2
Blair,

What's the best way to detect that the user has done something?  I need to
create some kind of "locking screen saver", and envision a background thread
that sleeps most of the time, and when it wakes with no time left on the
count down, it posts an action to lock the app.  Obviously, I don't want
normal system activity to be misinterpreted as user activity, nor do I want
to have to trigger/handle events from every aspect of the models involved.

Any ideas?

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: Detecting inactivity of the user

Blair McGlashan
Bill

You wrote in message news:bb2gsi$4sjte$[hidden email]...
>
> What's the best way to detect that the user has done something?  I need to
> create some kind of "locking screen saver", and envision a background
thread
> that sleeps most of the time, and when it wakes with no time left on the
> count down, it posts an action to lock the app.  Obviously, I don't want
> normal system activity to be misinterpreted as user activity, nor do I
want
> to have to trigger/handle events from every aspect of the models involved.
>
> Any ideas?

If you know you'll not have to run on Win9x, there is a very handy function
called GetLastInputInfo (added in Win2K) that should do exactly what you
want if called every now and then from a background thread:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/getlastinputinfo.asp

The help even mentions that the function "is useful for input idle
detection".

Another possibility is to modify InputState to record the last time a user
input message (keyboard or mouse) was received. All input is pumped through
the message loop, so this would be possible. However I think the overhead
might be high.

Other than that I think you will have to do a bit of web research to locate
some code, though it'll probably be for VB.

Regards

Blair


Reply | Threaded
Open this post in threaded view
|

Re: Detecting inactivity of the user

Bill Schwab-2
Blair,

> If you know you'll not have to run on Win9x, there is a very handy
function
> called GetLastInputInfo (added in Win2K) that should do exactly what you
> want if called every now and then from a background thread:

That will do the job.  The folks raising the concern won't even touch WinXP
re security concerns, so they'd be hard pressed to ask for 9x support.  Even
if they do, I can provide a partial solution for it too - it would simply
run the risk of "unfairly" logging the user out on occaision.

Thanks!

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]