Jump to content

Turn Monitor Off

- - - - -

  • Please log in to reply
11 replies to this topic

#1
LogicKills

LogicKills

    Programmer

  • Members
  • PipPipPipPip
  • 139 posts

//Turns monitor off for ~10 seconds then turns back on.

//LogicKills -> Codecall

#include <windows.h>

#include <ctime>


int main()

{

 

  int seconds = 10;

  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;

}


http://logickills.org
Science - Math - Hacking - Tech

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Nice code snippet Logic! You could convert that to allow the user to pass the amount of time he/she wants the monitor off as the first argument. This would be useful in a network environment where people want to reduce the amount of electricity their computers use. I say network because the administrators could remotely turn off all monitors for xxx amount of time after the work day is over.

#3
marwex89

marwex89

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 10,720 posts
Über cool :P I sure will use this one
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#4
morefood2001

morefood2001

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,720 posts
I might actually have a use for this! thanks :D

#5
marwex89

marwex89

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 10,720 posts
Uh-oh, your code seems to only work for win95.. (Or was it 98?) Reference: MSDN..
It didn't work with my computer :(
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#6
LogicKills

LogicKills

    Programmer

  • Members
  • PipPipPipPip
  • 139 posts

marwex89 said:

Uh-oh, your code seems to only work for win95.. (Or was it 98?) Reference: MSDN..
It didn't work with my computer :(

Um..
It works on XP.. Vista.. Me..
So.. I think you did something wrong lol
http://logickills.org
Science - Math - Hacking - Tech

#7
marwex89

marwex89

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 10,720 posts
No way :)
I use XP pro, SP3.. Perhaps it's my power settings? My monitor? Anyway.. I could test it on some other computer, though.
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#8
Egz0N

Egz0N

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,034 posts
i like it dude .. thnx a lot :D

#9
LogicKills

LogicKills

    Programmer

  • Members
  • PipPipPipPip
  • 139 posts
Just for kicks what kind of monitor do you have?
http://logickills.org
Science - Math - Hacking - Tech

#10
marwex89

marwex89

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 10,720 posts
I have a 22'' ASUS widescreen... Dunno the exact name, should I look it up, you think?
Hey! Check out my new Toyota keyboaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

#11
Jrb

Jrb

    Learning Programmer

  • Members
  • PipPipPip
  • 49 posts
Works perfectly for me, thanks. Gives me a few ideas :P

#12
duongvannam

duongvannam

    Newbie

  • Members
  • Pip
  • 1 posts
can you tell me why parameter clock_t don't declare?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users