Created
March 23, 2016 14:29
-
-
Save sankarara/5498337c33d42cb99efd to your computer and use it in GitHub Desktop.
AutoHotKey: Turn monitor off with a keyboard shortcut
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
Hi, i found that if you add the 1s sleep between the 2 calls works for me, like this: