AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how to turn off monitor?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
doru
Guest





PostPosted: Sat Jan 19, 2008 3:41 pm    Post subject: how to turn off monitor? Reply with quote

hi
in c++ can turn off monitor with command
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 2);

can i turn off monitor in autohotkey?
Back to top
Titan



Joined: 11 Aug 2004
Posts: 5390
Location: /b/

PostPosted: Sat Jan 19, 2008 3:46 pm    Post subject: Reply with quote

Using the SendMessage command. You will need to find the values of the constants.
_________________

Back to top
View user's profile Send private message Visit poster's website
i3egohan



Joined: 18 Jul 2006
Posts: 319

PostPosted: Sat Jan 19, 2008 3:47 pm    Post subject: Reply with quote

or sometimes you can use the button on the monitor, or simply pull the power cord.

Wink
_________________
`Autohotkey User`
- I3egohan
Back to top
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 1499

PostPosted: Sat Jan 19, 2008 5:50 pm    Post subject: Reply with quote

Code:
Sleep 1000 ; if you use this with a hotkey, not sleeping will make it so your keyboard input wakes up the monitor immediately
SendMessage 0x112, 0xF170, 1,,Program Manager ; send the monitor into standby (off) mode

_________________
My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags !
Back to top
View user's profile Send private message
Guest






PostPosted: Sat Jan 19, 2008 6:06 pm    Post subject: Reply with quote

i3egohan wrote:
or sometimes you can use the button on the monitor, or simply pull the power cord.

Wink


Is there any way to automate this using AHK?

I know it's not something you would normally do programmatically, but there is so much automation that I never would have expected AHK to be able to perform! So, is there a way of making a script that will physically push the monitor's on-off button?

Thank you!
Back to top
ManaUser



Joined: 24 May 2007
Posts: 906

PostPosted: Sat Jan 19, 2008 6:34 pm    Post subject: Reply with quote

Well, I guess if you positioned the monitor's power button in front of the CD tray...

But seriously, [VxE] gave the right answer.
Back to top
View user's profile Send private message
Guest






PostPosted: Sat Jan 19, 2008 6:47 pm    Post subject: Reply with quote

ManaUser wrote:
Well, I guess if you positioned the monitor's power button in front of the CD tray...

Brilliant! I hadn't even consiered the CD-tray as a robotic arm. I bet there's all sorts of things around the house you could do.

At the very least, you could have a warm tea waiting for you when you get home, by just having your tower upside-down (so the cd-tray is at the bottom, where the button I'm about to mention is) and across from a small microwave on your desk, which you set for 1 minute, in advance. Since a missed button-press wouoldn't do anything, and you've already set it for 1 minute, there's really nothing that could go wrong.

I wouldn't do anything that's more than 1 minute that way though...
Back to top
achinfish



Joined: 13 Aug 2006
Posts: 26

PostPosted: Sat Jan 19, 2008 8:57 pm    Post subject: Reply with quote

"Doc?"

"You've disintegrated Einstein!"

"One-point-twenty-one gigawatts!?"
Back to top
View user's profile Send private message
Gertlex



Joined: 29 Oct 2006
Posts: 27
Location: A2 MI

PostPosted: Mon Jul 21, 2008 9:33 pm    Post subject: Reply with quote

This is sort of on topic:

Prior to reformatting, I accomplished this by running screensaver with PostMessage. My screensaver did the job of turning off the screen. It was some screen saver file that I downloaded from a website full of neat little utilities like that. Found said website on this forum... but haven't been able to dig it back up.

Anyone familiar with what I'm talking about?
Back to top
View user's profile Send private message AIM Address
jak



Joined: 28 Feb 2006
Posts: 116

PostPosted: Sun Aug 10, 2008 12:43 am    Post subject: Reply with quote

[VxE] wrote:
Code:
Sleep 1000 ; if you use this with a hotkey, not sleeping will make it so your keyboard input wakes up the monitor immediately
SendMessage 0x112, 0xF170, 1,,Program Manager ; send the monitor into standby (off) mode


hi vxe -- is there a way to make this so that the screen does NOT come back on unless a SPECIFIC key is hit?

I realize the above puts the monitor into standby mode and thus any movement or key will wake it up, so this might require a different approach to the problem (ie, different from putting monitors into standby). I just want to blank the screens (monitors going to sleep would be great, ecology wise), but the important thing is I dont want them back on unless I hit a particular key and not just any key.

(the use of this here is: playing music at party, would like the laptop screen off while music plays, and I adjust the volume with a pc remote. Problem is: when i hit volume up/down on the remote, the laptop wakes up and shows the screen. Would like the screen to remain dark and only come on with a specific key and not just any input).

I tried the following which I thought would turn the monitors OFF (not go into STANDBY) and then turn them ON when ANY KEY was hit. (It doesnt work; the problem appears to be that the monitors dont go into any kind of OFF mode, they just go into standby as usual).


Code:
;in place of the 1, can use
;const int MONITOR_ON = -1;
;const int MONITOR_OFF = 2;
;const int MONITOR_STANBY = 1;

^+!left::
Sleep 1000 ; if you use this with a hotkey, not sleeping will make it so your keyboard input wakes up the monitor immediately
SendMessage 0x112, 0xF170, 2,,Program Manager ; send the monitor into off mode
;wait for a key to be pressed
Input, SingleKey, L1, {LControl}{RControl}{LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{AppsKey}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12}{Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins}{BS}{Capslock}{Numlock}{PrintScreen}{Pause} ;wait for a key to be pressed
SendMessage 0x112, 0xF170, -1,,Program Manager ; send the monitor into on mode
return


The problem appears to be that

Code:
SendMessage 0x112, 0xF170, 2,,Program Manager ; send the monitor into off mode


is not sending the monitors into any kind of OFF mode, seems to just put them into regular old standby.


Last edited by jak on Mon Aug 11, 2008 5:20 am; edited 1 time in total
Back to top
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 1499

PostPosted: Sun Aug 10, 2008 2:46 am    Post subject: Reply with quote

Unfortunately, I couldn't find any way to 'lock' a monitor into 'off' (or suspend) mode except the button on the monitor itself.

If you're using a laptop as a music/media center, you can simply close the lid to turn the screen off (adjust the settings by going to [Control Panel-->Display-->Screen Saver-->(Power)-->Advanced] and change the option for "when I close the lid...")

Otherwise, you can have a timer repeatedly sending the 'suspend' message and use a hotkey to toggle that timer on/off.
_________________
My Home Thread
More Common Answers: [1]. It's in the FAQ [2]. Ternary ( a ? b : c ) guide [3]. Post code inside [code][/code] tags !
Back to top
View user's profile Send private message
jak



Joined: 28 Feb 2006
Posts: 116

PostPosted: Sun Aug 10, 2008 5:38 am    Post subject: Reply with quote

Quote:
Unfortunately, I couldn't find any way to 'lock' a monitor into 'off' (or suspend) mode except the button on the monitor itself.

ok, thanks vxe. I gathered as much from the other similar threads on this forum. Bummer. Seems like a lot of folks were looking for that ability.

Quote:
If you're using a laptop as a music/media center, you can simply close the lid to turn the screen off

Ya my dell tends to overheat a bit when the lid is closed if its still running. thats ok tho.


Quote:
you can have a timer repeatedly sending the 'suspend' message and use a hotkey to toggle that timer on/off

yup, i stole your code that does that from another thread. It works well enough. I combined it with a "black screen drape" from yet another thread, so now when the monitors come alive for those few seconds, it isnt as jarring since there's a black drape window over the contents and thats what shows in those 2 seconds before they suspend again.

Separately, I also modified the "drape" into a "backdrop" (ie, allow the active window to show but blacken everything else on the screen -- us ADD sufferers use this to improve our focus and shut out other distractions on the screen while working Wink
Back to top
View user's profile Send private message
Guest






PostPosted: Thu Aug 28, 2008 3:23 pm    Post subject: Reply with quote

Any chance of sharing that code, jak? Smile
Back to top
BoBo²
Guest





PostPosted: Thu Aug 28, 2008 3:49 pm    Post subject: Reply with quote

Code:
SetTitleMatchMode, 2
TheDarkeningContent =
(
<html>
<body bgcolor="black" scroll="NO">
<font color="black">
BoBo is watching you!
</font>
</body>
</html>
)

IfNotExist, %A_ScriptDir%\TheDarkening.html
   FileAppend, %TheDarkeningContent%, %A_ScriptDir%\TheDarkening.html

!y::Run, "%ProgramFiles%\Internet Explorer\IEXPLORE.EXE" -k %A_ScriptDir%\TheDarkening.html ; run window in 'kiosk' mode
!x::WinClose, TheDarkening ; close window
Of course, it's not that effective when it comes to save energy. Embarassed
Noobish, but tested Cool
Back to top
Slanter



Joined: 28 May 2008
Posts: 405
Location: Minnesota, USA

PostPosted: Thu Aug 28, 2008 6:18 pm    Post subject: Reply with quote

Hey BoBo, instead of an HTML page in a browser, try this
Code:
Gui, Color, Black
Gui, -Caption +AlwaysOnTop
SysGet, Mon, Monitor
Return

!y::Gui, Show, w%MonRight% h%MonBottom% x0 y0
!x::Gui, Hide

_________________
Unless otherwise stated, all code is untested

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group