Running C++ script from a batch
Posted: 17 Mar 2016 19:36
I wanted to incorporate into a batch a C script to query monitor's EDID (restart monitor) in case such query is delayed at PC wakeup, and on-screen picture is lost. The batch can be started by a keyboard shortcut to its desktop shortcut, or by Win Scheduler. However, running below script has a side effect of Windows sending the monitor immediately to Sleep, while PC stays awake. Any way to correct the script & make a batch from it to avoid monitor sleep effect in Win 10 64-bit?
Code: Select all
#include
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// Turn off monitor
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 2);
// Turn on monitor
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) -1);
return 0;
}