Hack Forums
[C] C++ app that turns off Monitor - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C] C++ app that turns off Monitor (/showthread.php?tid=5146110)



C++ app that turns off Monitor - Deathskully66 - Jan 24, 2016

Well Guys i was Really bored Today so I wanted to make a C++ console application. This application lets your Monitor Sleep for a few seconds.

I added comments so you guys who are new to C++ can understand the code.
Link:w ww.mediafire.com/download/36gw25c6ouvhzb2/ TurnOffMonitor.rar

I placed some spaces since i cant make a link yet so yea Enjoy.
Code
#include <Windows.h>

int main()
{
    //turns off Monitor
    SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM)2);
    Sleep(5000); // the Monitor is turned off for 5 seconds
    //(Down) This line off code turns the monitor Back on.
    SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM)-1);
    return 0;
    // Returning 0 shuts off the application, so to run it again you would have to start it again.

}

Well looks like i made a mistake, if u have Visual Studio 2015 or probably any VS start it and you will see the effects.


* - _Mr2fadded_ - Jan 24, 2016

Screen cuts on with key input or mouse movent


* - Zakhaev11katona - Jan 25, 2016

it works perfect :) i love it :D