|
THis looks like a VB forum but I'm sure you guys will be able to help me out here.Please do read on.
I made 2 batch files using poweroff3.0 by Jorgen Bosman and Wizmo By Steve Gibson for the following purpose
1.mute and turnoff the monitor -mute with wizmo, turnoff with poweroff
2.unmute and power on monitor - unmute with wizmo, turn on with poweroff
the code for the two batch files is
-----------------------batch file#1--------------------------
:: monoffmute.bat
:: turn off monitor and mutes sound
::
@ECHO OFF
C:\poweroff monitor_off
C:\wizmo mute=1
-----------------------batch file #2-------------------------
::mononsoundon.bat
:: turn on monitor and un-mutes sound
::
@ECHO OFF
C:\poweroff monitor_on
C:\wizmo mute=0
---------------------------------------------------
I then assigned 2 separate keys on my Pinnacle TV tuner (PCTV plus 110i) for running both above batch files.
My problem is that the monitor turns off from the remote(and green light turns to amber on monitor), but turns back on because TV/VIDEO/MUSIC app is playing.any activity on the screen turns on the monitor.So the trick doesn't work as I envisaged.I want the monitor to stay turned off no matter what it is playing.It should turn on only when i press the button that i programmed to do so!
How do I achieve that?
Thanks a lot for your time
Neelesh Bhagwat
If you have a suggestion please post or mail me on bhagwatnp2@gmail.com
Neelesh
"wannabe" HTPC enthusiast
|
|
|
|
|
hey guys im super new to all this coding stuff... and i thought it would be pretty neat to make a program where i press a button and monitor turns off...
so #1 wat do i do with that source thing i downloaded...wen i double click the files they open in c++ and i have no idea wat to do with that code...#2 can i make this work in vb6? any help would be great ty!!!
|
|
|
|
|
Choose an appropriate language and an appropriate book...
For C/C++ read this article [^].
|
|
|
|
|
First, thanks for the code.
Saved me some time looking up win api code
But what is really the diffence between standby and off?
I've tested both (I'm currently on my laptop) and can't see any diffence...
Regards,
Oyvind Eriksen
|
|
|
|
|
I have to say I don't ever know...
|
|
|
|
|
hi all,
i have impelemented by your method, it works fine, but not for below case:
while playing songs by mediaplayer (or other players), i manually switch monitor off by that funciton, it works till player change to next song.
anyway to keep it always blank unless only when i keypressed or mousemoved?
thanks
|
|
|
|
|
Take a look at Michael Dunn's post (FYI)...
|
|
|
|
|
Is there any way to change monitor's (display)brightness and contrast by code?
Thx for any help...
|
|
|
|
|
Did u got any updates on ur query, even im having the same need, help me out if u found a solution. thanks a ton!!
|
|
|
|
|
WmiSetBrightness Method of the WmiMonitorBrightnessMethods Class
The WmiSetBrightness method sets the display brightness of a computer monitor.
|
|
|
|
|
|
Hmmm, obviously Raymond is right.
I wrote:
If you don't want to bother creating a window to send the message to, you can send the message to all top level windows (HWND_BROADCAST) or you can use GetDesktopWindow function sending the message to the desktop window.
So it's preferable to say "always create a window and use its handle" or if you don't want to bother creating a window to send the message to then don't use this method.
|
|
|
|
|
Great program! I like it.
And is there a similar solution to directly turn off a hard-disk?
I need such a small program for testing purposes!
Please help
|
|
|
|
|
Hi,
Can you use this to detect when a screen goes into a different power mode? I would like to make an application which pauses itself when the machine is unattended for a period of time and was going to use the screen going into power-save mode. I found the SENS COM+ interface which notifies an application of a bunch of useful things. I had assumed that the screensaver notification it delivers would also tell me about the screen blanking if the energystar setting is selected, but it doesn't.
|
|
|
|
|
|
I rated this as a 5 (to my surprise), because I like simple solutions to problems. I know finding the solution is not always easy, which you did. I hope some one adds this to a FAQs some where.
INTP
Every thing is relative...
|
|
|
|
|
|
I can use SendMessage or PostMessage to turn on or turn off the monitor. The problem is I have multiple VGA cards that link to multiple monitors. I just want to turn off the individual one. Can anybody help me?
|
|
|
|
|
Hi, I think this is not possible using the standard WinAPI.
|
|
|
|
|
Hi,
This is nice exe and working perfectly.But i tried using C# and found its not workking , i think i am missing somewhere plz guid me .
I used the code as folows.
The name space I used is :
using System.Runtime.InteropServices;
Now I declared the varrbale
const int MONITOR_ON = -1;
const int MONITOR_OFF = 2;
const int WM_SYSCOMMAND = 0x0112;
const int SC_MONITORPOWER = 0xF170;
const UInt32 ES_CONTINUOUS = 0x80000000;
//declared methods
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool PostMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);
[DllImport("user32.dll")]
static extern IntPtr GetDesktopWindow();
// written following code in page load.
System.Threading.Thread.Sleep(2000);
PostMessage(GetDesktopWindow(), WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);
System.Threading.Thread.Sleep(2000);
Please help me out.
Regards,
Lalit Narayan Dubey
S/W Developer , Noida
|
|
|
|
|
Try this
<br />
using System.Runtime.InteropServices;<br />
[DllImport("user32.dll")]<br />
private static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);<br />
public int WM_SYSCOMMAND = 0x0112;<br />
public int SC_MONITORPOWER = 0xF170;<br />
private System.Windows.Forms.Button button1;<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
int result = 0;<br />
result = SendMessage(ActiveForm.Handle.ToInt32(), WM_SYSCOMMAND, SC_MONITORPOWER, 2);<br />
}<br />
|
|
|
|
|
Hi,
Its really working great.thanks. I tried one thing more to have the desktop alwayas live. from control pannel setting i set turn off monitor in 1 min.
and written the code like this in button click
private void button1_Click(object sender, System.EventArgs e)
{
int result = 0;
//
// get handle to active form
//
result = SendMessage(ActiveForm.Handle.ToInt32(), WM_SYSCOMMAND, SC_MONITORPOWER, -1);
//
}
but it dont work, the monitor get power down.
What else need to change in application. please help me out here too.
Regards,
Lalit Narayan Dubey
S/W Developer,Noida
|
|
|
|
|
Hmmm, would you like to disable monitor power off function?
Well, use this code but it's not C# code.
#include <windows.h><br />
<br />
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);<br />
<br />
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)<br />
{<br />
static TCHAR szAppName[] = TEXT("Disabler");<br />
HWND hwnd;<br />
MSG msg;<br />
WNDCLASS wndclass;<br />
<br />
wndclass.style = CS_HREDRAW | CS_VREDRAW;<br />
wndclass.lpfnWndProc = WndProc;<br />
wndclass.cbClsExtra = 0;<br />
wndclass.cbWndExtra = 0;<br />
wndclass.hInstance = hInstance;<br />
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);<br />
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);<br />
wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);<br />
wndclass.lpszMenuName = NULL;<br />
wndclass.lpszClassName = szAppName;<br />
<br />
if (!RegisterClass(&wndclass)) <br />
{<br />
MessageBox(NULL, TEXT("This program requires Windows NT!"), szAppName, MB_ICONERROR);<br />
return 0;<br />
}<br />
<br />
hwnd = CreateWindow(szAppName, TEXT("Screensaver && Monitor Power Saving are temporary disabled..."),<br />
WS_OVERLAPPEDWINDOW,<br />
150, 150,<br />
500, 250,<br />
NULL, NULL, hInstance, NULL);<br />
<br />
ShowWindow(hwnd, nCmdShow);<br />
UpdateWindow(hwnd);<br />
<br />
while(GetMessage(&msg, NULL, 0, 0)) <br />
{<br />
TranslateMessage(&msg);<br />
DispatchMessage(&msg);<br />
}<br />
<br />
return ((int) msg.wParam);<br />
}<br />
<br />
<br />
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)<br />
{<br />
switch (message)<br />
{<br />
case WM_SYSCOMMAND:<br />
<br />
switch (wParam) <br />
{ <br />
case SC_SCREENSAVE:<br />
case SC_MONITORPOWER:<br />
<br />
return 0;<br />
}<br />
<br />
break;<br />
<br />
case WM_DESTROY:<br />
<br />
PostQuitMessage(0);<br />
<br />
return 0;<br />
}<br />
<br />
return DefWindowProc(hwnd, message, wParam, lParam);<br />
}<br />
|
|
|
|
|
Works great ... in c++ ... how do i get it to work in vb ?
Stoopid SendMessage declare in vb doesnt work
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
any ideas ?
:: For all the hours you save writing user progs in vb, you spend twice as long implenting one tiny windows API call ...
|
|
|
|
|
Oh, see it can be done in VB
Note the commented line that *doesnt* work ...
(Tested on Win2k sp4)
Private Declare Function SendMessageVal Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Sub WakeMonitor()
'SendMessageVal &HFFFF, &H112, &HF170, -1 ' Doesnt work !&@!
SendMessageVal &HFFFF, &H112, 61808, -1
End Sub
|
|
|
|
|