Detecting computer inactivity

  • Thread starter Thread starter bzh_29
  • Start date Start date
B

bzh_29

Hi,

I would like to be able to detect computer inactivity in order to
launch some admin process ...

Is there a simple way like a windows event ... I would like something
that will not be CPU and time consuming ...

Thanks !
 
See GetIdleMinutes API function

---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : GUI Controls For Drop-In Windows Explorer like Shell
Browsing Functionality For Your App (.Net & ActiveX Editions).
EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensions.Net : Develop all shell extensions,explorer bars and BHOs
rapidly in .Net
 
Hi,
Thanks !

I think I've already check this API but to use it (I may confuse) I
have to check every X sec to see if it is OK or not ... I'd rather
prefer that someone send me an event ...



G Himangi a écrit :
 
bzh_29 said:
Hi,
Thanks !

I think I've already check this API but to use it (I may confuse) I
have to check every X sec to see if it is OK or not ... I'd rather
prefer that someone send me an event ...


GetIdleMinutes should not be used anymore. Use GetLastInputInfo instead:
http://msdn2.microsoft.com/en-us/library/ms646302.aspx

There is not event but you can check the idle time every n seconds (and if
the intended idle time is reached, you can send an event in order to have
one).


Armin
 
Thanks !
I will try.
I'm just scare about the time/cpu consuming of checking every n
seconds ...

Armin Zingler a écrit :
 
bzh_29 said:
Thanks !
I will try.
I'm just scare about the time/cpu consuming of checking every n
seconds ...


As the function doesn't do a lot, the call won't take forever...
Well, 10,000,000 calls took 0.78 seconds here, so...


Armin
 
You use very little CPU time for such polling. Do not use a loop, but
instead a Timer (or you could use a loop in a thread, too -- with
Thread.Sleep to release time).

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
Dick Grier a écrit :
You use very little CPU time for such polling. Do not use a loop, but
instead a Timer (or you could use a loop in a thread, too -- with
Thread.Sleep to release time).

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.

Thanks to all of you !

I'm starting now :) !
 
Back
Top