Query if Monitor is off?

Reboot /M1 powers the monitor off. Is there a way to query in a batch file if the monitor is actually off? (My batch file occasionally ftp's the screen @snapshot[] and it would be nice to know if the screen is on or off).

From: TonyT
| Reboot /M1 powers the monitor off. Is there a way to query in a batch
| file if the monitor is actually off? (My batch file occasionally
| ftp's the screen @snapshot[] and it would be nice to know if the
| screen is on or off).

When the monitor is turned off by REBOOT /M1 (or its equivalent), would @SNAPSHOT return the "virtual screen", i.e., that which would be displayed if the monitor were on?

A question similar to the one in the OP that's related to REBOOT /W: would internal variables _READY and _HDRIVES indicate whether or not the disk drive power is currently on?
--
Steve

From: TonyT
| Reboot /M1 powers the monitor off. Is there a way to query in a batch
| file if the monitor is actually off? (My batch file occasionally
| ftp's the screen @snapshot[] and it would be nice to know if the
| screen is on or off).

When the monitor is turned off by REBOOT /M1 (or its equivalent), would @SNAPSHOT return the "virtual screen", i.e., that which would be displayed if the monitor were on?

A question similar to the one in the OP that's related to REBOOT /W: would internal variables _READY and _HDRIVES indicate whether or not the disk drive power is currently on?
--
Steve

Click to expand...

I am not actually using @Snapshot, but IrfanView /capture and the captures always show the pictures as if the screen is on. That PC is thousands of miles away from me, so I'd like to know if the monitor state is really off.

From: TonyT
| I am not actually using @Snapshot, but IrfanView /capture and the captures always show
| the pictures as if the screen is on. That PC is thousands of miles away from me, so I'd like
| to know if the monitor state is really off.

Is the real issue that you want to know the state of the monitor of a remote system under your control? And your approach is to capture the screen display of TCC running on that system?

BTW, please do NOT quote signatures and signature separators (the line containg just two hyphens followed by a space, see below in this post). Those of us who try to respond to your post by email, all of your post remains unquoted. I had to manually quote it above. Quote only as little as is necessary to understand your new post.
--
Steve

| Is the real issue that you want to know the state of the monitor of a remote system under your control? And your approach is to capture the screen display of TCC running on that system?

The PC is under my control, unattended far away. I basically want the monitor off all the time to save power and not burn a hole in the laptop screen etc.. So I issue a monitor off command. Frequently the system posts the screen capture (with stuff it is crunching out) to a homepage and that is working fine. But is the monitor really off? Or has somebody touched a key and it is on again? An internal variable like @MonitorStatus[] would be ideal, but I looked far and wide for a way to tell if it's on with no luck. "Win32_DesktopMonitor Class Status" I suppose could in a c program, but I don't know how to do that.

| BTW, please do NOT quote signatures and signature separators (the line containg just two hyphens followed by a space, see below in this post). Those of us who try to respond to your post by email, all of your post remains unquoted. I had to manually quote it above. Quote only as little as is necessary to understand your new post.

I'm quite new to forums, so I deleted the hyphens and next line but don't know if it is better now.

| Why not use the Windows power management options to turn the screen off after a while?

The Notebook is actually doing data acquisition for building movements and in windstorms somebody might actually want to observe it on site - so it turning off unexpectedly would be annoying.

Now there is just no way for me to tell the monitor status remotely (or the automatic procedures that the notebook is running) if I can not find some utility or internal variable to determine the status.

| Why not use the Windows power management options to turn the screen off after a while?

Another example: Say I want to turn the screen ON for this monitoring laptop for people on site when wind-speeds it monitors are above 30mph. How could I ever tell if it is actually on when this laptop is thousands of miles away from me. I might "blindly" think my batch files turned it on, but is it? A %_MonitorStatus[] or %MonitorStatus[] like utility or variable is what I need then I can simply DisplayWrite it on the screen before I capture it and post the screen capture to a webpage I frequently look at.

|A %_MonitorStatus[] or %MonitorStatus[] like utility or variable is what I need

I hope I'm wrong but I don't think this is easy to do it. I googled quite a
bit. There may be a way to do it with WMIQUERY/@WMI but I couldn't find it
(anyone?). I found some rather complicated code (which uses the setup API) that
can tell the difference between these:

|A %_MonitorStatus[] or %@MonitorStatus[] like utility or variable is what I need

| I hope I'm wrong but I don't think this is easy to do it. I googled quite a
bit. There may be a way to do it with WMIQUERY/@WMI but I couldn't find it
(anyone?). I found some rather complicated code (which uses the setup API) that
can tell the difference between these:

Code:

# Monitors = 4
[Default Monitor]
PowerState = 1
Thanks for your interesting idea. I searched the registry for "PowerState" but only found Settings nothing for state. Even windows own powercfg does not report the state, just settings.

|on my Dell WKS with two physical monitors before/after I put them into standby.

Interestingly, this simple code can tell whether the monitor is in (any) power
saving mode. But it can't tell if I have physically turned the monitor off. I
could easily include it in one of my plugins but I am uncertain about its value.

|on my Dell WKS with two physical monitors before/after I put them into standby.

| Interestingly, this simple code can tell whether the monitor is in (any) power
saving mode. But it can't tell if I have physically turned the monitor off.

Thanks Vince. I think I can use your code to do exactly what I want. I am a bit embarrassed I could not compile the code yet with TinyC ( http://bellard.org/tcc/ ) but will keep trying. It is such simple code but I am a lousy c programmer (expert in Fortran that tells my age). Could you just send me the compiled program, e.g. anonymously put in the inbox of ftp.mka.com ?

I don't need to know if unplugged, just if it is in the power saving mode.

|Thanks Vince. I think I can use your code to do exactly what I want. I am a bit embarrassed I could not compile the code yet with TinyC ( http://bellard.org/tcc/ ) but will keep trying. It is such simple code but I am a lousy c programmer (expert in Fortran that tells my age). Could you just send me the compiled program, e.g. anonymously put in the inbox of ftp.mka.com ?
|
|I don't need to know if unplugged, just if it is in the power saving mode.

I could certainly do that but I'll have to tidy it up first, I'll call it
QUERYLCD.EXE, and make it a console app printing **and** returning 1 or 0. Look
for it in a few minutes.

|| I rather doubt that you will because there are no includes for the header files in Vince's source code.
|
|I had added the #include <windows.h> and even #include <stdio.h> but I guess more was needed.

Those two are the only includes I had in there. You probably also needed a
compiler option for Unicode because I used L"\\\\.\\LCD"; it's /D "_UNICODE" /D
"UNICODE" here. Just getting rid of the "L" qualifier might work as well.

|| Hence I still don't have a solution to know whether the remote laptop's screen is on or off.
|
|Trying again to make it show as a new post ...
|
|vefatica solved it! Using a setup API approach that looks quite ingenious and works on all devices I tried.
|
|Rex Conn: Any possibility to incorporate his method to make a new internal variable _MonitorStatus[] in a future release of TCC that shows if a monitor is on or in sleeping state?

I can only take credit for building some code I googled up. It's not OO but it
uses a lot of STL stuff (for which there's no real need ... Rex, do you use STL
stuff in TCMD?). I'm going to streamline it and see how costly it is to put
into one of my plugins. If it's particularly costly, I'll try rewriting it
without STL.

Basically, it uses the setup API to get it->Description.c_str() and
it->PowerData.PD_MostRecentPowerState for the instances of the "Monitor" classes
(see
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E96E-E325-11CE-BFC1-08002BE10318}).

I have to admit to never having used the Fortran (and indeed the last time I did anything with Fortran - converting Dungeon to run on IBM's mainframe VM OS for a bureau's games system - was back in the early 1980s) but I have used Open Watcom C for virtually the whole of its existence, since my employer previously used the commercial Watcom C for the Windows version of our cross-platform tools.

Any possibility to incorporate his method to make a new internal variable _MonitorStatus[] in a future release of TCC that shows if a monitor is on or in sleeping state?

Click to expand...

I did manage to get it into a plugin. My first attempt, leaving the Googled code basically "as is", added about 15Kb to my plugin. After getting rid of the STL stuff, a function template, and the getting of device names, I whittled that down to about 1Kb. Rex is welcome to the code but since it's a hack of someone else's code I'll take neither credit nor blame for it.

What I have now works like this, with the second example being when the monitor(s) are in power saving mode.

to see how many devices exist and their descriptions ... and to experiment as to which of them suit his purposes.

I have two physical monitors attached to a Dell WKS here. And here that registry key enumerates 4 devices; their descriptions are: "Default Monitor", "Default Monitor", "Dell 1908FP(Digital)", and "Plug and Play Monitor" (a bit confusing). In my tests, I always get the same result for all 4.

What "I'D" really like @execstr[] to return more than "first" line ...
example exesctr[fc whatever,1]
as an example - fc.exe returns the command parameters while the second
line produces the result I want
"FC: no differences encountered" -a- Plugin would work just as well

Staff Member

What "I'D" really like @execstr[] to return more than "first" line ...
example exesctr[fc whatever,1]
as an example - fc.exe returns the command parameters while the second
line produces the result I want
"FC: no differences encountered" -a- Plugin would work just as well

Click to expand...

@EXECSTR already supports an optional argument to specify the line you want.