ActiveState Code

Recipe 576752: Monitor standby


Monitor On/Off

C++
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
// Turns monitor off for ~10 seconds then turns back on
// LogicKills 
// Have Fun and head over to logickills.org for new code~
#include <windows.h>
#include <ctime>

int main()
{
 
  int seconds = 20;
  clock_t delay = seconds *CLOCKS_PER_SEC;
  clock_t start = clock();
  while(clock() - start < delay){
  SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 2);}
  SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 2);
    return 0;
}

Discussion

Monitor On/Off

Sign in to comment