0

I have a TV hooked up to my laptop via HDMI all day/night. In the daytime, most of the time I just have a radio station on the TV. Essentially I'm trying to make a screensaver for just the TV, to prevent burn-in.

I currently have a SWF file with random shapes being made that I put on full-screen, but it's a case of remembering to put it on; and also, it's a little bit of a pain to get it off if I need to quickly demo something on the TV.

How can I detect if monitor #2 is idle for 5 mins? Then if the mouse moves to the TV, an event is fired.

The width of monitor #1 is 1366px, if the solution requires knowing the x pos of the mouse.

I don't really mind what language this is made in, but I'd prefer C#.

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
  • Use C# to Detect if the mouse is idle: http://stackoverflow.com/questions/6282298/detecting-idle-users-in-winforms then when that happens, read: How to use C# to programatically turn on/off a monitor: http://stackoverflow.com/questions/713498/turn-on-off-monitor – Eric Leschinski Jan 18 '13 at 14:31
  • 1
    Instead of add lots of language tags, it would be nicer to add a tag for the Operating System you are using... – Veger Jan 18 '13 at 14:31
  • @EricLeschinski Thanks, but it's detecting the idle time on a specific monitor that's the problem, not the turning the display off. – Danny Beckett Jan 18 '13 at 14:33
  • 1
    @Veger I've edited the tags, I'd prefer a C# solution. – Danny Beckett Jan 18 '13 at 14:34

1 Answers1

2

You can determine the current cursor position via System.Windows.Forms.Cursor.Position. The simplest (but perhaps not best) approach would be to poll this periodically. If you have not seen the mouse move on that screen within a certain amount of time, you could launch the SWF. Also, when the mouse does move on that screen, you can close the SWF.

Dark Falcon
  • 43,592
  • 5
  • 83
  • 98
  • Thanks, that works great! `while (true) { if (Cursor.Position.X <= Screen.PrimaryScreen.Bounds.Width) MessageBox.Show("hi"); Thread.Sleep(100); }` – Danny Beckett Jan 18 '13 at 15:03