473,486 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 13401
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
1833
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
6179
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
1674
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
5731
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
2001
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
6530
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
5878
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
13107
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
2890
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
7094
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
6964
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
7123
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
7173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7305
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5427
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4863
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
259
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.