1

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!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Simkoo
  • 74
  • 1
  • 10
  • You mean whether he is actually looking at the desktop background with no windows open? But still, say you are not looking at the desktop than why wouldn't you want to change the background so the next time he is staring at it he will see the new background? (wherever I write he , you may read she or it as well) – Peter Bons Dec 31 '18 at 08:29
  • i would like there to be a slideshow of backgrounds, a bit like windows already does. but only have the slideshow change when someone is actually looking at it. (hopefully this increases performance) – Simkoo Dec 31 '18 at 08:31
  • 2
    I should think the code that (continually) checks if someone is using the computer will have more negative impact on performance than the simple loading of the background image at intervals. – Johan Donne Dec 31 '18 at 08:38
  • Yeah, i guess that would be true, maybe this isn't the best situation to do this sort of a check. But is there even a way to check whether someone is on the desktop? if someone knows i would still love to know just for the sake of knowing. but maybe i'll reconsider doing this check in this script :) – Simkoo Dec 31 '18 at 08:43
  • Perhaps you find this interesting: https://stackoverflow.com/questions/203384/how-to-tell-when-windows-is-inactive – C.Evenhuis Dec 31 '18 at 08:44
  • That IS very interesting. thanks, this will help! – Simkoo Dec 31 '18 at 08:56

1 Answers1

2

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/
Io-oI
  • 2,514
  • 3
  • 22
  • 29
S.Maneesh
  • 60
  • 6
  • Thanks, this would be quite an effective way of solving the problem. It isn't quite the solution i was looking for, but thanks anyway! – Simkoo Dec 31 '18 at 08:49