Script to sleep monitors + other devices

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Hitaku
Posts: 17
Joined: 14 Mar 2017, 00:57

Script to sleep monitors + other devices

12 Jun 2019, 23:00

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
Rohwedder
Posts: 7622
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Script to sleep monitors + other devices

13 Jun 2019, 04:06

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
Hitaku
Posts: 17
Joined: 14 Mar 2017, 00:57

Re: Script to sleep monitors + other devices

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
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.
Last edited by Hitaku on 14 Jun 2019, 05:39, edited 1 time in total.
SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: Script to sleep monitors + other devices

13 Jun 2019, 19:25

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?
Hitaku
Posts: 17
Joined: 14 Mar 2017, 00:57

Re: Script to sleep monitors + other devices

14 Jun 2019, 05:30

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.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 336 guests