Created
October 23, 2019 23:36
-
-
Save hexiyou/10e4b259335dbf92fe993c24a8bec654 to your computer and use it in GitHub Desktop.
Turn monitor off with a keyboard shortcut with AutoHotKey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; This is part of my AutoHotkey [1] script that turns off my monitor when I | |
; press Win+\. | |
; It also turns the screensaver on at the same time, so that Windows Live | |
; Messenger (and any other programs) know I am away. | |
; I don't have a password on my screensaver, so there is a second version | |
; (Win+Shift+\) that locks the PC as well. | |
; Note: Sometimes the monitor comes back on after a second and I have to | |
; press it again. Not sure why. Adding "Sleep" to pause first didn't help. | |
; [1]: http://www.autohotkey.com/ | |
; Win+\ | |
#\:: | |
SendMessage 0x112, 0xF140, 0, , Program Manager ; Start screensaver | |
SendMessage 0x112, 0xF170, 2, , Program Manager ; Monitor off | |
Return | |
; Win+Shift+\ | |
#+\:: | |
Run rundll32.exe user32.dll`,LockWorkStation ; Lock PC | |
Sleep 1000 | |
SendMessage 0x112, 0xF170, 2, , Program Manager ; Monitor off | |
Return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment