Page 1 of 1

Script to sleep monitors + other devices

Posted: 12 Jun 2019, 23:00
by Hitaku
I've found the script below and it works perfectly with putting my monitors to sleep. I'd like to edit it to put my keyboard, mouse, and mouse pad to sleep as well if possible.

Code: Select all

F1::PostMessage, 0x0112, 0xF170, % (i:=!i)?2:-1,, A ; << Press F1 to toggle On/Off

Re: Script to sleep monitors + other devices

Posted: 13 Jun 2019, 04:06
by Rohwedder
Hallo,
try:

Code: Select all

F1::PostMessage, 0x0112, 0xF170, % (i:=!i)?2:-1,, A ; << Press F1 to toggle On/Off
F2 Up:: ; << Press F2 to toggle On/Off
IF !F2 := !F2
	Return
BlockInput, On
While, !GetKeyState("F2","P")
	Sleep, 100
BlockInput, Off
Return
Note: F2 might have no effect if UAC is enabled or the script has not been run as administrator.
https://www.autohotkey.com/docs/commands/BlockInput.htm

Re: Script to sleep monitors + other devices

Posted: 13 Jun 2019, 12:12
by Hitaku
Rohwedder wrote:
13 Jun 2019, 04:06

Code: Select all

F1::PostMessage, 0x0112, 0xF170, % (i:=!i)?2:-1,, A ; << Press F1 to toggle On/Off
F2 Up:: ; << Press F2 to toggle On/Off
IF !F2 := !F2
	Return
BlockInput, On
While, !GetKeyState("F2","P")
	Sleep, 100
BlockInput, Off
Return
This script disables all monitors, mouse, and mouse pad. Unfortunately, the keyboard is still on. I'm sure it doesn't matter what kind of keyboard it is, but for what it's worth, it's a Corsair Vengeance K70 Blue.

Re: Script to sleep monitors + other devices

Posted: 13 Jun 2019, 19:25
by SOTE
Hitaku wrote:
13 Jun 2019, 12:12
Rohwedder wrote:
13 Jun 2019, 04:06

Code: Select all

F1::PostMessage, 0x0112, 0xF170, % (i:=!i)?2:-1,, A ; << Press F1 to toggle On/Off
F2 Up:: ; << Press F2 to toggle On/Off
IF !F2 := !F2
	Return
BlockInput, On
While, !GetKeyState("F2","P")
	Sleep, 100
BlockInput, Off
Return
Very close! This script disables all monitors, mouse, and mouse pad. Unfortunately, the keyboard is still on. I'm sure it doesn't matter what kind of keyboard it is, but for what it's worth, it's a Corsair Vengeance K70 Blue.
I'm confused, so have some questions:

1) If you disable the keyboard, how do you intend to wake your computer back up from sleep mode?

Usually people touch a key, then the computer wakes up from sleep because of that. Do you want to put everything to sleep, then wake it back up at a set time instead?

2) What difference does it make to include the keyboard, based on power consumption?

That's assuming that the purpose of the script is to put everything to sleep to save power, or do you have some other reason?

Re: Script to sleep monitors + other devices

Posted: 14 Jun 2019, 05:30
by Hitaku
1) If you disable the keyboard, how do you intend to wake your computer back up from sleep mode?

Usually people touch a key, then the computer wakes up from sleep because of that. Do you want to put everything to sleep, then wake it back up at a set time instead?
I typically move my mouse to wake my devices. When I run the script it disables the lights, but I can still use the mouse to turn everything back on.
2) What difference does it make to include the keyboard, based on power consumption?

That's assuming that the purpose of the script is to put everything to sleep to save power, or do you have some other reason?
My computer has a lot of RGB lights, but when I go to sleep it's very distracting. Sometimes I want to keep my computer running over night to do something, so I wanted to make a keybind that turns off the lights / monitors.


Edit: I'm pretty inexperienced at Autohotkey and I didn't notice at first, but the script modification you made seems to block inputs. I guess I never realized that the initial script also turns off my mouse / mouse pad lights as well. To be clear, my goal is to just disable my monitors / all of my RGB lighting until I move my mouse / press a key on the keyboard. I'm even fine disabling the keyboard (if that's the only way to turn off the lights) if I can turn it back on again when I move the mouse. I'm fairly sure that was my fault for not being clear enough, my apologies.