3

Possible Duplicate:
C# - Detect time of last user interaction with the OS

I'm building a Windows Form software with VS 2010/ C#, I want to update the software every day when the user don't use the computer.

Can anyone suggest me how can I detect if the user uses the computer right now?? I've tried to check if the user click on the keyboard or moveing the mouse for the last 10 min, but the problem is if he see a movie and he don't move anything.. I'm acctuly want any suggestion how to check if the computer turn on and the user don't use it..

thanks you all have a nice day

Community
  • 1
  • 1
TEST ME
  • 123
  • 2
  • 9
  • 3
    http://stackoverflow.com/questions/1037595/c-sharp-detect-time-of-last-user-interaction-with-the-os – Adam Aug 21 '12 at 15:36
  • I think your problem is defining what "use" means. – jwrush Aug 21 '12 at 15:36
  • Adam, that's just half of a solution which specifically doesn't work for the case they mention. – Joey Aug 21 '12 at 15:36
  • I think there is no way to 100% detect it. – Anton Sizikov Aug 21 '12 at 15:41
  • Allow the user to pick a scheduled time that works for them. *Then* if at that time there is no user input (via `BOOL WINAPI GetLastInputInfo()`) then go ahead and do your update since they've already signed off on it. – erodewald Aug 21 '12 at 15:41
  • as I can see the real problem is to update SW every day when user dosen't use the computer. You may write a service which autorun when PC is switch on.Then the service may check the last day it was run(written by this service in a file or registry in previous session) If the time interval is more then a day run your update procedure. – Arseny Aug 21 '12 at 15:44
  • I think the best you can hope for is to define your own conditions and then code towards them. You might be able to see if a thread has SetThreadExecutionState(ES_DISPLAY_REQUIRED) set, which will take care of multimedia or things that prevent screen saving. – Reacher Gilt Aug 21 '12 at 15:50
  • thank you all.. is any one have a sample how to use GetLastInputInfo() – TEST ME Aug 21 '12 at 15:55
  • thank you all again, I find good explain on it in the like http://www.blackwasp.co.uk/InactivityDetection.aspx – TEST ME Aug 21 '12 at 16:10

2 Answers2

0

You don't need to make this a bigger problem that it is. I would keep it simple. First update could be triggered on windows start. You can do this be packing your update software inside windows service and set startup type to automatic. Periodical updates (when machine is running) can be done at hours that user does not work, like at 2:00AM... You shoud pick the time that suits you best. Alternative to that is monitoring machine CPU, but as I was saying, I would keep it simple.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
Gregor Primar
  • 6,759
  • 2
  • 33
  • 46
0

I find good solution for it + demo in the link http://www.blackwasp.co.uk/InactivityDetection.aspx

TEST ME
  • 123
  • 2
  • 9