Determining If A Monitor Is Off: "AnswerDetermining If A Monitor Is Off
*
Wednesday, July 18, 2007 5:03 PMstack Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
Sign In to Vote
0
Sign In to Vote
I've found code that will turn a monitor on and off:
Code Snippet
#include
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// Eliminate user's interaction for 500 ms
Sleep(500);
// Turn off monitor
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 2);
// Turn on monitor
// SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) -1);
// Low power monitor
// SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 1);
return 0;
}
Now I am looking for code that will tell me if a monitor is on or off. Anyone have any examples?
o ReplyReply
o QuoteQuote
Answers
*
Thursday, July 19, 2007 8:10 AMBruno van Dooren Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
Answer
Sign In to Vote
0
Sign In to Vote
I don't know. Try asking in the appropriate platform SDK nntp newsgroup
http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx
Even if you can query the monitor state, this won't tell you if the monitor itself is powered on.
At home I still use a 19' iyama crt. Windows doesn't know when I press the monitor power button.
Btw: have you tried google or www.codeproject.com ?
o ReplyReply
o QuoteQuote
All Replies
*
Thursday, July 19, 2007 8:10 AMBruno van Dooren Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
Answer
Sign In to Vote
0
Sign In to Vote
I don't know. Try asking in the appropriate platform SDK nntp newsgroup
http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx
Even if you can query the monitor state, this won't tell you if the monitor itself is powered on.
At home I still use a 19' iyama crt. Windows doesn't know when I press the monitor power button.
Btw: have you tried google or www.codeproject.com ?
o ReplyReply
o QuoteQuote
– Enviado usando a Barra de Ferramentas Google"
segunda-feira, 22 de novembro de 2010
How to detect if monitor was on or off with C#
How to detect if monitor was on or off with C#: "AnswerHow to detect if monitor was on or off with C#
*
Monday, June 01, 2009 8:48 AMRiteru Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
Sign In to Vote
0
Sign In to Vote
I'm trying to write a software to detect the status of monitor (or perhap HD LCD television screen) in order to create a report about the availability of the output screen.
- I've tried to use WMI (Win32_DesktopMonitor ) to check availability but it alway return 3 which mean On, no matter my computer LCD screen is On or Off;
Anyone have any idea on detecting the monitor status?
PS. The LCD screen i'm using connected to my PC via DVI port, I'm not sure yet which port will be used in the real run (DVI, Serial , etc) so I'm trying to find a solution that can support all this port.
o ReplyReply
o QuoteQuote
Answers
*
Tuesday, June 02, 2009 12:32 PMJagadeesan Kandasamy Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
Answer
Sign In to Vote
0
Sign In to Vote
I hope this might be helpful...
Try to use with GetDesktopWindow(), The below code is just to switch on / off the moniter, from this you can try to the status as well.
[DllImport(
'user32.dll')]
static
extern IntPtr SendMessage(IntPtr hWnd, uint Msg,
IntPtr wParam, IntPtr lParam);
//Or
[DllImport(
'user32.dll', SetLastError = true)]
static
extern bool PostMessage(IntPtr hWnd, uint Msg,
IntPtr wParam, IntPtr lParam);
//Or
[DllImport(
'user32.dll')]
static
extern bool PostThreadMessage(uint idThread, uint Msg,
UIntPtr wParam, IntPtr lParam);
//Or
[DllImport(
'user32.dll', SetLastError=true, CharSet=CharSet.Auto)]
static
extern bool SendMessageCallback(IntPtr hWnd, uint Msg,
UIntPtr wParam, IntPtr lParam,
SendMessageDelegate lpCallBack,
UIntPtr dwData);
//Or
[DllImport(
'user32.dll', SetLastError=true, CharSet=CharSet.Auto)]
static
extern bool SendNotifyMessage(IntPtr hWnd, uint Msg,
UIntPtr wParam, IntPtr lParam);
//Or
[DllImport(
'user32.dll')]
private
static extern IntPtr GetDesktopWindow();
//Or
[DllImport(
'user32.dll', SetLastError = true)]
static
extern IntPtr FindWindow(string lpClassName, string lpWindowName);
//Or
[DllImport(
'user32.dll', SetLastError = true)]
static
extern IntPtr FindWindowEx(IntPtr hwndParent,
IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
const
int SC_MONITORPOWER = 0xF170;
const
int WM_SYSCOMMAND = 0x0112;
const
int MONITORON = -1;
const
int MONITOROFF = 2;
const
int MONITORSTANBY = 1;
int
HWND_BROADCAST = 0xffff; //the message is sent to all top-level windows in the system
int
HWND_TOPMOST = -1;
int
HWND_TOP = 0; //
int
HWND_BOTTOM = 1; //limited use
int
HWND_NOTOPMOST = -2; //
Form frm =
new Form();
Frm.Handle();
SendMessage(ValidHWND, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOROFF );
SendMessage(ValidHWND, WM_SYSCOMMAND, SC_MONITORPOWER, MONITORON);
Regards, Jagadeesan
o Marked As Answer byBin-ze ZhaoMicrosoft, ModeratorFriday, June 05, 2009 2:04 AM
o
o ReplyReply
o QuoteQuote
All Replies
*
Tuesday, June 02, 2009 12:32 PMJagadeesan Kandasamy Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
Answer
Sign In to Vote
0
Sign In to Vote
I hope this might be helpful...
Try to use with GetDesktopWindow(), The below code is just to switch on / off the moniter, from this you can try to the status as well.
[DllImport(
'user32.dll')]
static
extern IntPtr SendMessage(IntPtr hWnd, uint Msg,
IntPtr wParam, IntPtr lParam);
//Or
[DllImport(
'user32.dll', SetLastError = true)]
static
extern bool PostMessage(IntPtr hWnd, uint Msg,
IntPtr wParam, IntPtr lParam);
//Or
[DllImport(
'user32.dll')]
static
extern bool PostThreadMessage(uint idThread, uint Msg,
UIntPtr wParam, IntPtr lParam);
//Or
[DllImport(
'user32.dll', SetLastError=true, CharSet=CharSet.Auto)]
static
extern bool SendMessageCallback(IntPtr hWnd, uint Msg,
UIntPtr wParam, IntPtr lParam,
SendMessageDelegate lpCallBack,
UIntPtr dwData);
//Or
[DllImport(
'user32.dll', SetLastError=true, CharSet=CharSet.Auto)]
static
extern bool SendNotifyMessage(IntPtr hWnd, uint Msg,
UIntPtr wParam, IntPtr lParam);
//Or
[DllImport(
'user32.dll')]
private
static extern IntPtr GetDesktopWindow();
//Or
[DllImport(
'user32.dll', SetLastError = true)]
static
extern IntPtr FindWindow(string lpClassName, string lpWindowName);
//Or
[DllImport(
'user32.dll', SetLastError = true)]
static
extern IntPtr FindWindowEx(IntPtr hwndParent,
IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
const
int SC_MONITORPOWER = 0xF170;
const
int WM_SYSCOMMAND = 0x0112;
const
int MONITORON = -1;
const
int MONITOROFF = 2;
const
int MONITORSTANBY = 1;
int
HWND_BROADCAST = 0xffff; //the message is sent to all top-level windows in the system
int
HWND_TOPMOST = -1;
int
HWND_TOP = 0; //
int
HWND_BOTTOM = 1; //limited use
int
HWND_NOTOPMOST = -2; //
Form frm =
new Form();
Frm.Handle();
SendMessage(ValidHWND, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOROFF );
SendMessage(ValidHWND, WM_SYSCOMMAND, SC_MONITORPOWER, MONITORON);
Regards, Jagadeesan
o Marked As Answer byBin-ze ZhaoMicrosoft, ModeratorFriday, June 05, 2009 2:04 AM
o
– Enviado usando a Barra de Ferramentas Google"
*
Monday, June 01, 2009 8:48 AMRiteru Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
Sign In to Vote
0
Sign In to Vote
I'm trying to write a software to detect the status of monitor (or perhap HD LCD television screen) in order to create a report about the availability of the output screen.
- I've tried to use WMI (Win32_DesktopMonitor ) to check availability but it alway return 3 which mean On, no matter my computer LCD screen is On or Off;
Anyone have any idea on detecting the monitor status?
PS. The LCD screen i'm using connected to my PC via DVI port, I'm not sure yet which port will be used in the real run (DVI, Serial , etc) so I'm trying to find a solution that can support all this port.
o ReplyReply
o QuoteQuote
Answers
*
Tuesday, June 02, 2009 12:32 PMJagadeesan Kandasamy Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
Answer
Sign In to Vote
0
Sign In to Vote
I hope this might be helpful...
Try to use with GetDesktopWindow(), The below code is just to switch on / off the moniter, from this you can try to the status as well.
[DllImport(
'user32.dll')]
static
extern IntPtr SendMessage(IntPtr hWnd, uint Msg,
IntPtr wParam, IntPtr lParam);
//Or
[DllImport(
'user32.dll', SetLastError = true)]
static
extern bool PostMessage(IntPtr hWnd, uint Msg,
IntPtr wParam, IntPtr lParam);
//Or
[DllImport(
'user32.dll')]
static
extern bool PostThreadMessage(uint idThread, uint Msg,
UIntPtr wParam, IntPtr lParam);
//Or
[DllImport(
'user32.dll', SetLastError=true, CharSet=CharSet.Auto)]
static
extern bool SendMessageCallback(IntPtr hWnd, uint Msg,
UIntPtr wParam, IntPtr lParam,
SendMessageDelegate lpCallBack,
UIntPtr dwData);
//Or
[DllImport(
'user32.dll', SetLastError=true, CharSet=CharSet.Auto)]
static
extern bool SendNotifyMessage(IntPtr hWnd, uint Msg,
UIntPtr wParam, IntPtr lParam);
//Or
[DllImport(
'user32.dll')]
private
static extern IntPtr GetDesktopWindow();
//Or
[DllImport(
'user32.dll', SetLastError = true)]
static
extern IntPtr FindWindow(string lpClassName, string lpWindowName);
//Or
[DllImport(
'user32.dll', SetLastError = true)]
static
extern IntPtr FindWindowEx(IntPtr hwndParent,
IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
const
int SC_MONITORPOWER = 0xF170;
const
int WM_SYSCOMMAND = 0x0112;
const
int MONITORON = -1;
const
int MONITOROFF = 2;
const
int MONITORSTANBY = 1;
int
HWND_BROADCAST = 0xffff; //the message is sent to all top-level windows in the system
int
HWND_TOPMOST = -1;
int
HWND_TOP = 0; //
int
HWND_BOTTOM = 1; //limited use
int
HWND_NOTOPMOST = -2; //
Form frm =
new Form();
Frm.Handle();
SendMessage(ValidHWND, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOROFF );
SendMessage(ValidHWND, WM_SYSCOMMAND, SC_MONITORPOWER, MONITORON);
Regards, Jagadeesan
o Marked As Answer byBin-ze ZhaoMicrosoft, ModeratorFriday, June 05, 2009 2:04 AM
o
o ReplyReply
o QuoteQuote
All Replies
*
Tuesday, June 02, 2009 12:32 PMJagadeesan Kandasamy Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
Answer
Sign In to Vote
0
Sign In to Vote
I hope this might be helpful...
Try to use with GetDesktopWindow(), The below code is just to switch on / off the moniter, from this you can try to the status as well.
[DllImport(
'user32.dll')]
static
extern IntPtr SendMessage(IntPtr hWnd, uint Msg,
IntPtr wParam, IntPtr lParam);
//Or
[DllImport(
'user32.dll', SetLastError = true)]
static
extern bool PostMessage(IntPtr hWnd, uint Msg,
IntPtr wParam, IntPtr lParam);
//Or
[DllImport(
'user32.dll')]
static
extern bool PostThreadMessage(uint idThread, uint Msg,
UIntPtr wParam, IntPtr lParam);
//Or
[DllImport(
'user32.dll', SetLastError=true, CharSet=CharSet.Auto)]
static
extern bool SendMessageCallback(IntPtr hWnd, uint Msg,
UIntPtr wParam, IntPtr lParam,
SendMessageDelegate lpCallBack,
UIntPtr dwData);
//Or
[DllImport(
'user32.dll', SetLastError=true, CharSet=CharSet.Auto)]
static
extern bool SendNotifyMessage(IntPtr hWnd, uint Msg,
UIntPtr wParam, IntPtr lParam);
//Or
[DllImport(
'user32.dll')]
private
static extern IntPtr GetDesktopWindow();
//Or
[DllImport(
'user32.dll', SetLastError = true)]
static
extern IntPtr FindWindow(string lpClassName, string lpWindowName);
//Or
[DllImport(
'user32.dll', SetLastError = true)]
static
extern IntPtr FindWindowEx(IntPtr hwndParent,
IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
const
int SC_MONITORPOWER = 0xF170;
const
int WM_SYSCOMMAND = 0x0112;
const
int MONITORON = -1;
const
int MONITOROFF = 2;
const
int MONITORSTANBY = 1;
int
HWND_BROADCAST = 0xffff; //the message is sent to all top-level windows in the system
int
HWND_TOPMOST = -1;
int
HWND_TOP = 0; //
int
HWND_BOTTOM = 1; //limited use
int
HWND_NOTOPMOST = -2; //
Form frm =
new Form();
Frm.Handle();
SendMessage(ValidHWND, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOROFF );
SendMessage(ValidHWND, WM_SYSCOMMAND, SC_MONITORPOWER, MONITORON);
Regards, Jagadeesan
o Marked As Answer byBin-ze ZhaoMicrosoft, ModeratorFriday, June 05, 2009 2:04 AM
o
– Enviado usando a Barra de Ferramentas Google"
SC_MONITORPOWER in Windows 7?
SC_MONITORPOWER in Windows 7?: "SC_MONITORPOWER in Windows 7?
*
Wednesday, January 13, 2010 1:46 PMRodTech Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
Sign In to Vote
0
Sign In to Vote
Hi, I have developed a program which turns off the monitor by sending message :
SendMessage(-1, WM_SYSCOMMAND, SC_MONITORPOWER, 2)
The problem is that is not working in Windows 7. Does anybody know if WM_SYSCOMMAND and SC_MONITORPOWER are still supported in Win7?
In case is not, what are the replacemente for this actions? thanks in advance
Rod
o ReplyReply
o QuoteQuote
All Replies
*
Sunday, February 28, 2010 6:31 PMRaymond Rogers Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
Sign In to Vote
0
Sign In to Vote
I'm seeing the same problem with my application. Have you found a solution for this yet?
o ReplyReply
o QuoteQuote
*
Friday, June 11, 2010 5:30 PMRomashka_Sky Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
Sign In to Vote
0
Sign In to Vote
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
o ReplyReply
o QuoteQuote
– Enviado usando a Barra de Ferramentas Google"
*
Wednesday, January 13, 2010 1:46 PMRodTech Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
Sign In to Vote
0
Sign In to Vote
Hi, I have developed a program which turns off the monitor by sending message :
SendMessage(-1, WM_SYSCOMMAND, SC_MONITORPOWER, 2)
The problem is that is not working in Windows 7. Does anybody know if WM_SYSCOMMAND and SC_MONITORPOWER are still supported in Win7?
In case is not, what are the replacemente for this actions? thanks in advance
Rod
o ReplyReply
o QuoteQuote
All Replies
*
Sunday, February 28, 2010 6:31 PMRaymond Rogers Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
Sign In to Vote
0
Sign In to Vote
I'm seeing the same problem with my application. Have you found a solution for this yet?
o ReplyReply
o QuoteQuote
*
Friday, June 11, 2010 5:30 PMRomashka_Sky Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
Sign In to Vote
0
Sign In to Vote
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
o ReplyReply
o QuoteQuote
– Enviado usando a Barra de Ferramentas Google"
Visual Basic :: Turn Monitor Off Or Place It On Standby...
Visual Basic :: Turn Monitor Off Or Place It On Standby...: "Turn Monitor Off Or Place It On Standby...
I have found this code splattered all over VBF, or code similar, which I have modified...
VB Code:
Option Explicit Private Declare Function SendMessage Lib 'user32' Alias 'SendMessageA' (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long Private Const WM_SYSCOMMAND = &H112Private Const SC_MONITORPOWER = &HF170 Private Sub cmdTurnOFF_Click() Debug.Print SendMessage(Form1.hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, 2&)End Sub Private Sub cmdStandby_Click() Debug.Print SendMessage(Form1.hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, 1&)End Sub Private Sub cmdTurnON_Click() Debug.Print SendMessage(Form1.hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, -1&)End Sub
But it doesn't work...I alwasy get a 0 returned from the SendMessage and the monitor does absolutely nowt
Anyone got any ideas?
Woka
– Enviado usando a Barra de Ferramentas Google"
I have found this code splattered all over VBF, or code similar, which I have modified...
VB Code:
Option Explicit Private Declare Function SendMessage Lib 'user32' Alias 'SendMessageA' (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long Private Const WM_SYSCOMMAND = &H112Private Const SC_MONITORPOWER = &HF170 Private Sub cmdTurnOFF_Click() Debug.Print SendMessage(Form1.hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, 2&)End Sub Private Sub cmdStandby_Click() Debug.Print SendMessage(Form1.hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, 1&)End Sub Private Sub cmdTurnON_Click() Debug.Print SendMessage(Form1.hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, -1&)End Sub
But it doesn't work...I alwasy get a 0 returned from the SendMessage and the monitor does absolutely nowt
Anyone got any ideas?
Woka
– Enviado usando a Barra de Ferramentas Google"
quinta-feira, 4 de novembro de 2010
16 bit in Windows 7 with XP mode
16 bit in Windows 7 with XP mode
Assuming you can run the program on Windows XP, you might be able to run it. If you meet the hardware requirements you can go ahead and try it out. See the following link for the requirements and other information about Windows XP mode:
http://www.microsoft.com/windows/virtual-pc/get-started.aspx
Assuming you can run the program on Windows XP, you might be able to run it. If you meet the hardware requirements you can go ahead and try it out. See the following link for the requirements and other information about Windows XP mode:
http://www.microsoft.com/windows/virtual-pc/get-started.aspx
Assinar:
Postagens (Atom)