Turn off display (laptop)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
sobuj53
Posts: 55
Joined: 19 Mar 2015, 16:08

Turn off display (laptop)

Post by sobuj53 » 05 May 2020, 06:58

Greetings,

I've a AHK script that I use to turn off my laptop display,

Code: Select all

; Ctrl+F1 to turn off display
; esc to turn on again
^F1::
KeyWait, CTRL
KeyWait, F1
;KeyWait, SHIFT
KeyWait, Escape
Gui,Color,0x000000
Gui,-Caption
Gui,Show, NA w%A_ScreenWidth% h%A_ScreenHeight%
Loop
{
	If GetKeyState("Escape","P") 
	{
		BlockInput Off
		Break
	}
	else if (A_TimeIdlePhysical<1000)
	{
		SendMessage, 0x112, 0xF170, 2,, A
		BlockInput On
	}
}
Gui,Destroy
Return
The expected behavior of this script is to turn off display when pressed Ctrl+F1 and block keyboard and mouse input from turning it on again unless pressed and hold ESC key. The script does turns off the display and block keyboard and mouse from turning it on (fairly) but the problem is the Esc key doesn't always break the script and turn on the display, it sometimes causes display to flicker. I'd really appreciate any advise to improve this script. Thank you for your time and help.

Return to “Ask for Help (v1)”