473,390 Members | 1,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

Monitor status

Is there a way to query the monitor status, to know if it is on or off
in C#? I found that WM_SYSCOMMAND is sent to WndProc when the monitor
goes on and off but im not sure to find out if that message is always
just about the monitor.

Thanks for any help.

Jan 5 '06 #1
7 13384
Nevermind...
WM_SYSCOMMAND does not notify WndProc. So does anyone know what does
notify WndProc when the monitor backlight comes back on?

Jan 5 '06 #2
> Is there a way to query the monitor status, to know if it is on or off
in C#? I found that WM_SYSCOMMAND is sent to WndProc when the monitor
goes on and off but im not sure to find out if that message is always
just about the monitor.

Thanks for any help.


How are you going to code if your monitor is off? ;)
Jan 5 '06 #3
Hi,

I think you asked this yesterday !
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dave" <dc*****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Is there a way to query the monitor status, to know if it is on or off
in C#? I found that WM_SYSCOMMAND is sent to WndProc when the monitor
goes on and off but im not sure to find out if that message is always
just about the monitor.

Thanks for any help.

Jan 5 '06 #4
I did but no one answered my question. I think most people
misunderstood me.

When the machine is idle for 20 mins (or however long it is set in
Power Options) the monitor backlight turns off. The power button is
not pressed on the monitor. My application plays many different types
of media including movies and audio. But when they press a button to
make the monitor go to sleep (or the backlight turning off) everything
is paused. Now my problem is that when the mouse is moved or a key is
pressed the monitor automatically comes back on. I want to know when
this happens so that i can start the media files to play again.

Thanks again for the help.

Jan 5 '06 #5
If there is not a way to determine this, is there at least a way to
tell when the mouse is clicked? Anywhere on the screen?

Jan 5 '06 #6

"Dave" <dc*****@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I did but no one answered my question. I think most people
misunderstood me.

When the machine is idle for 20 mins (or however long it is set in
Power Options) the monitor backlight turns off. The power button is
not pressed on the monitor. My application plays many different types
of media including movies and audio. But when they press a button to
make the monitor go to sleep (or the backlight turning off) everything
is paused. Now my problem is that when the mouse is moved or a key is
pressed the monitor automatically comes back on. I want to know when
this happens so that i can start the media files to play again.

Thanks again for the help.


I assume you are talking about power management features that are enabled on
your system.
While it's not possible to detect when the monitor is turned off due to
power management actions, it's quite possible to detect when a system enters
the 'suspend' state and returns from suspend state.

The following simple console sample shows you how you can use
System.Managent to watch these power status events.
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Management;
class Program {
public static void Main() {
Program we = new Program();
ManagementEventWatcher w= null;
WqlEventQuery q = new WqlEventQuery();;
ManagementOperationObserver observer = new ManagementOperationObserver();
// Bind to local machine
ManagementScope scope = new ManagementScope("root\\CIMV2");
try {
q.EventClassName = "Win32_PowerManagementEvent";
Console.WriteLine(q.QueryString);
w = new ManagementEventWatcher(scope, q);

w.EventArrived += new EventArrivedEventHandler(we.UsbEventArrived);
w.Start();
Console.ReadLine(); // block main thread for test purposes only
}
finally {
w.Stop();
}
}
public void UsbEventArrived(object sender, EventArrivedEventArgs e) {
//Get the Event object and display it
foreach(PropertyData pd in e.NewEvent.Properties) {
Console.WriteLine("\n================Power event===================");
Console.WriteLine("{0}", pd.Value); // possible values 4, 7, 10, 11, 18
see WMI SDK docs
}
}
}
Willy.
Jan 5 '06 #7
Hi,

"Dave" <dc*****@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I did but no one answered my question. I think most people
misunderstood me.
U had some reply , from Willy and from me IIRC.
When the machine is idle for 20 mins (or however long it is set in
Power Options) the monitor backlight turns off. The power button is
not pressed on the monitor. My application plays many different types
of media including movies and audio. But when they press a button to
make the monitor go to sleep (or the backlight turning off) everything
is paused. Now my problem is that when the mouse is moved or a key is
pressed the monitor automatically comes back on. I want to know when
this happens so that i can start the media files to play again.


You can get a notification when the system enters suspends , the most
visible consequence of this is the display been turned off, but possible the
HDD is also stopped, etc.

What we said before is that it's a one way communication, from the computer
to the monitor, if you physically turn off the monitor the system gets no
notification.

Check willy post for some code to detect when the power notification
changes.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jan 6 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Michel G | last post by:
I need to know by programation if the monitor is On or Off. Is there a way to request the status of the monitor (on , power save mode , off). Thak you
2
by: Mike | last post by:
Hellos again, I seem to be having a weird issue. Whenever DB2 Health monitor seems to run, all connections to the database seem to just lock up. For example: (and this seems consistent) In list...
10
by: Mark | last post by:
I am working on a monitor system - web page that will show what processes are running on different computers. How would I get such information? All I need is a name of a process (title on a taskbar...
3
by: AndersBj | last post by:
Is there a way to monitor a windows service using asp.net? I would like to have a web page listing 5-6 services and their status (running, stopped etc). Any tips on how to do this would be...
0
by: muntyanu | last post by:
Hi All, I need to find out current status of my monitor: is it OFF or ON ? I can set status by SendMessage(handle, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON) But before setting status I have...
2
by: wugon.net | last post by:
env: db2 LUW v8 + aix We encounter some java applications status did not change and keep in "Federated request pending" for a long time. we try issue db2 "force applications <handle id>" to...
4
by: buu | last post by:
so, I have a private object as system.threading.AutoResetEvent, and I would like to read it's current status. currently I have an another boolean object wich I update together with an...
5
by: Laetitia | last post by:
Hi All Please can anyone advise whether it is possible to display messages in the status bar. I have a number of update queries which will be run and need to find a way to identify which...
6
by: alag20 | last post by:
Hi Guys, I am working on a new project to provide some kind of monitor on a webpage. Basically i have a c# application which does task A, B....X, Y, Z. Now we would like to view what task it is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.