J
janhm
Hello.
I have created a windows service that is supposed to turn the monitor on/off
at specific times a day, but my timer dosn't seem to work.
on my Service Start i set :
timer1.Enabled = true;
timer1.Interval = 1500;
and on my timer_tick i set this.
int intHour = DateTime.Now.Hour;
if (intHour < 7)
SendMessage((int)-1, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);
else if (intHour > 20)
SendMessage((int)-1, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);
else
SendMessage((int)-1, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON);
but it dosnt work.
i tried setting
System.Threading.Thread.Sleep(3000);
SendMessage((int)-1, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);
System.Threading.Thread.Sleep(10000);
SendMessage((int)-1, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON);
on Service Start, and this works fine, so I know my Sendmessage works.
Any advice?
/Jan
I have created a windows service that is supposed to turn the monitor on/off
at specific times a day, but my timer dosn't seem to work.
on my Service Start i set :
timer1.Enabled = true;
timer1.Interval = 1500;
and on my timer_tick i set this.
int intHour = DateTime.Now.Hour;
if (intHour < 7)
SendMessage((int)-1, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);
else if (intHour > 20)
SendMessage((int)-1, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);
else
SendMessage((int)-1, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON);
but it dosnt work.
i tried setting
System.Threading.Thread.Sleep(3000);
SendMessage((int)-1, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);
System.Threading.Thread.Sleep(10000);
SendMessage((int)-1, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON);
on Service Start, and this works fine, so I know my Sendmessage works.
Any advice?
/Jan