Home » How To » How To Automatically Turn Off the Screen When You Lock Windows

How To Automatically Turn Off the Screen When You Lock Windows

Learn how to configure Windows to automatically turn off the screen when you lock your computer to save power.

Locking Windows is a relatively simple task. Just press the “Windows key + L” shortcut. By default, locking the system shows the lock screen wallpaper. However, what if you also want Windows to turn off the screen as soon as you lock the system? This not only eliminates the distraction of the lock screen wallpaper but also reduces the overall power consumption of your computer, especially desktops with high-resolution / high-refresh-rate monitors.

While Windows doesn’t have a built-in option to instantly turn off the screen when you lock it, we can create a simple script using AutoHotkey, a free and open-source application that automates Windows tasks. This guide shows you how to do it in simple steps. Let’s get started.

Good to know: Best AutoHotkey scripts for every Windows user

Before You Start

  • Before proceeding, download AutoHotkey from this official page. After downloading, install it by double-clicking the downloaded installer.

Automatically Turn OFF the Screen On Locking Windows

  1. Open the Start menu by pressing the “Windows key”.
  2. Search for and open “Notepad“.
  3. Paste the following script into Notepad.
    ; Override the Win+L hotkey
    #L::
    {
    DllCall("user32.dll\LockWorkStation") ; lock PC
    Sleep(1000) ; wait 1 second
    SendMessage(0x0112, 0xF170, 2, , "ahk_id " 0xFFFF) ; send command to turn off monitor
    }
  4. Press “Ctrl + S“.
  5. Go to a folder where you want to save the file.
  6. Type “TurnOffScreenOnLock.ahk” in the “File name” field.
  7. Select “All files” from the “File type” dropdown menu.
  8. Click the “Save” button.
  9. Close Notepad.
  10. Find the saved file using File Explorer and double-click it.
  11. The script runs in the background.
  12. From now on, locking the system using the “Windows key + L” shortcut also turns off the monitor.

Good to know: AutoHotkey script to make a window transparent

Detailed Steps (With Screenshots)

First, we need to create an AutoHotkey script that turns off the monitor when the computer is locked. To do that, open the Notepad app by searching for it in the Start menu.

open notepad

Once the Notepad window opens, paste the following script into it. The script overrides the default “Windows key + L” shortcut to not only lock the system but also turn off the screen.

; Override the Win+L hotkey
#L::
{
  DllCall("user32.dll\LockWorkStation") ; lock PC
  Sleep(1000) ; wait 1 second
  SendMessage(0x0112, 0xF170, 2, , "ahk_id " 0xFFFF) ; send command to turn off monitor
}
autohotkeyscript to turn off screen on locking Windows

After that, press the “Ctrl + S” shortcut or select the “File” > “Save” option. This opens the Save dialog. Here, go to a folder where you want to save the file, type “TurnOffScreenOnLock.ahk” as the file name, select “All files” from the “File type” dropdown menu, and click “Save“. This action saves the script file with the .ahk extension in your chosen location. For example, I’ve saved my file to the desktop.

save autohotkey script

Once the script file has been created, open the File Explorer using the “Windows key + E” shortcut, find the file, and double-click it. This action executes the script, and it runs in the background.

launch autohotkey script

As long as the script is running in the background, locking the system using the default “Windows key + L” shortcut locks the system and immediately turns off the monitor screen. If you don’t want to run the script manually every time, you can add it to the Windows startup. That way, the script runs automatically when you turn on your computer.

If you have any questions or need help, comment below. I’ll be happy to assist.

Good to know: How to disable Caps Lock in Windows 11 & 10

Leave a Comment

Your email address will not be published. Required fields are marked *