Simkoo
Simkoo

Reputation: 74

How to detect whether user is on the desktop C# winforms

I was making a program that changes the desktop background, but there is no need to do this when the user is not on the desktop.

I was wondering if there was a way to detect if the user was on the desktop.

I was also thinking an alternative could be checking whether the user is on any other processes, but I don't know how to do this either.

(I would happily provide my code if necessary)

I'm sorry for posting such a broad question, I hope there is a way to do this though.

Thanks to anyone who can help!

Upvotes: 1

Views: 910

Answers (1)

S.Maneesh
S.Maneesh

Reputation: 60

If you want to check application in idle condition then you have to do below:

  1. Add a timer control to your application.
  2. Subscribe to mouseover and keydown events - when they fire, reset the timer.
  3. When the timer fires (ie mouse hasn't moved and key's haven't been pressed for x amount of time), write your logic.

And If want to check idle condition of desktop then below references will be useful for you:

  1. Detecting that the user is away from the PC with .NET
  2. Detecting that the user is away from the PC with .NET
  3. http://www.codeproject.com/KB/cs/ApplicationIdle.aspx
  4. http://msdn.microsoft.com/en-us/library/system.windows.forms.application.idle.aspx
  5. http://ellisweb.net/2008/02/detecting-application-idle-state-in-windows-forms/

Upvotes: 2

Related Questions