Newsgroups: comp.windows.ms.programmer
Path: utzoo!utgpu!watserv1!watmath!hyper.hyper.com!bonneau
From: bonneau@hyper.hyper.com (Paul Bonneau)
Subject: Re: detecting user inactivity
Message-ID: <1991Jun12.215158.16959@hyper.hyper.com>
Reply-To: bonneau@hyper.UUCP (Paul Bonneau,,)
Organization: HyperCube Inc.
References: <17190004@hpsciz.sc.hp.com>
Date: Wed, 12 Jun 1991 21:51:58 GMT

In article <17190004@hpsciz.sc.hp.com> bruceh@hpsciz.sc.hp.com (Bruce Haines) writes:
>
>	Any ideas on how to sense user "inactivity".  I'd like to set a
>	timer that would go off if a user hasn't generated any keyboard/mouse
>	input. Like whatever a screen saver app must do...?

One approach that springs to mind is to write a .dll and
install a system-wide windows hook in it (SetWindowsHook()
type WH_GETMESSAGE since user generated events are posted to
the event queue).  Each time you get a user-generated event,
call GetTickCount() and store the result in a static.  Before
doing so, however, compare the returned value with the old
contents of the static, and if the elapsed time is greater
than your threshold, install your timer.

This is a pretty rough sketch, but it should work.

cheers - Paul Bonneau.
