Anyone know how to modify this program so that it turns a monitor ON instead of OFF?

Infohawk

Lifer
Jan 12, 2002
17,844
1
0
This thread shows how you can manually make a monitor sleep. It's great, but I want one that will wake it up too.

Why you ask? To schedule monitor uptime and downtime. (And no the display options in wxp are not enough. I don't want a timer).

int main(int argc, char *argv[])
{
Sleep(1000);
PostMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 1);

return 0;
}

So, anyone see how this could be modified to make the monitor wake up?
 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
Turn off:
PostMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);

Standby:
PostMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 1);

Turn on:
PostMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, -1);
 

Infohawk

Lifer
Jan 12, 2002
17,844
1
0
Originally posted by: xtknight
Turn off:
PostMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);

Standby:
PostMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 1);

Turn on:
PostMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, -1);

Cool. Thanks! So the rest stays the same? (I can't program). Now to look for a simple windows compiler... Is this C++?
 

BlueWeasel

Lifer
Jun 2, 2000
15,944
475
126
Originally posted by: xtknight
Turn off:
PostMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);

Standby:
PostMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 1);

Turn on:
PostMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, -1);

Nice, now can you make us some EXE out of that? :D
 

Infohawk

Lifer
Jan 12, 2002
17,844
1
0
Originally posted by: BlueWeasel

Nice, now can you make us some EXE out of that? :D

Or can someone lay out how to do this in windows?

I've tried downloading a couple compilers but they all bitch about something different.
 

Infohawk

Lifer
Jan 12, 2002
17,844
1
0
ANyone decent with compiling?

I get this error when I download the free MS stuff:

C:\Program Files\Microsoft Visual C++ Toolkit 2003>cl Sleep.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

Sleep.cpp
Sleep.cpp(3) : fatal error C1083: Cannot open include file: 'windows.h': No such
file or directory
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Post the source code or E-Mail to me as a zip file and I will see what I can do.

To lazy to download and build source file myself.
 

Infohawk

Lifer
Jan 12, 2002
17,844
1
0
This is what was mentioned on the other site (along with changes suggested by xtknight). [Unless there's a way for you to host file somewhere probably not worth bothering though since I don't receive email]
 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
Originally posted by: MSCoder610
Here, try this: http://s95030374.onlinehome.us/files/Montool.zip

Just basically compiled the above code in DevC++ and added commandline switches. So run it with any of these:

montool -off
montool -on
montool -standby

much thanks! i don't have VC++ installed right at the moment...

Infohawk: For a free C++ compiler for Windows, take a look at Microsoft Visual Studio 2005 Express. Yes, this does contain .NET, but you can compile C++ exes that don't use .NET.

http://lab.msdn.microsoft.com/vs2005/default.aspx