 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
doru Guest
|
Posted: Sat Jan 19, 2008 3:41 pm Post subject: how to turn off monitor? |
|
|
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/
|
Posted: Sat Jan 19, 2008 3:46 pm Post subject: |
|
|
Using the SendMessage command. You will need to find the values of the constants. _________________
 |
|
| Back to top |
|
 |
i3egohan
Joined: 18 Jul 2006 Posts: 319
|
Posted: Sat Jan 19, 2008 3:47 pm Post subject: |
|
|
or sometimes you can use the button on the monitor, or simply pull the power cord.
 _________________ `Autohotkey User`
- I3egohan |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1499
|
Posted: Sat Jan 19, 2008 5:50 pm Post subject: |
|
|
| 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 |
|
 |
Guest
|
Posted: Sat Jan 19, 2008 6:06 pm Post subject: |
|
|
| i3egohan wrote: | or sometimes you can use the button on the monitor, or simply pull the power cord.
 |
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
|
Posted: Sat Jan 19, 2008 6:34 pm Post subject: |
|
|
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 |
|
 |
Guest
|
Posted: Sat Jan 19, 2008 6:47 pm Post subject: |
|
|
| 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
|
Posted: Sat Jan 19, 2008 8:57 pm Post subject: |
|
|
"Doc?"
"You've disintegrated Einstein!"
"One-point-twenty-one gigawatts!?" |
|
| Back to top |
|
 |
Gertlex
Joined: 29 Oct 2006 Posts: 27 Location: A2 MI
|
Posted: Mon Jul 21, 2008 9:33 pm Post subject: |
|
|
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 |
|
 |
jak
Joined: 28 Feb 2006 Posts: 116
|
Posted: Sun Aug 10, 2008 12:43 am Post subject: |
|
|
| [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 |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1499
|
Posted: Sun Aug 10, 2008 2:46 am Post subject: |
|
|
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 |
|
 |
jak
Joined: 28 Feb 2006 Posts: 116
|
Posted: Sun Aug 10, 2008 5:38 am Post subject: |
|
|
| 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  |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Aug 28, 2008 3:23 pm Post subject: |
|
|
Any chance of sharing that code, jak?  |
|
| Back to top |
|
 |
BoBo² Guest
|
Posted: Thu Aug 28, 2008 3:49 pm Post subject: |
|
|
| 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.
Noobish, but tested  |
|
| Back to top |
|
 |
Slanter
Joined: 28 May 2008 Posts: 405 Location: Minnesota, USA
|
Posted: Thu Aug 28, 2008 6:18 pm Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|