Implementing a Custom Solution for Turning Off the Screen When Locking Windows 10 or 11 PC
Users frequently lock their Windows 11 computers using the Windows key + L shortcut, but this leaves the screen active. The goal is to have the screen turn off immediately for energy saving and privacy when the computer is locked, without altering the screen sleep timer settings for other scenarios.
This issue pertains to systems running Windows 11 where users require an immediate screen sleep function upon locking their PC.
Create a PowerShell script shortcut that turns off the screen. Assign a keyboard shortcut to this script for ease of use. The steps are as follows:
- Create a new shortcut on the desktop.
- In the shortcut target, enter the PowerShell command to turn off the screen.
powershell.exe -windowstyle hidden -command "(Add-Type '[DllImport(\"user32.dll\")] public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(-1, 0x0112, 0xF170, 2)"
- Set a keyboard shortcut for this script, such as Ctrl + Alt + S.
- Use this new shortcut in combination with Windows key + L to lock the computer and turn off the screen simultaneously.
This solution is a workaround that combines the screen-off functionality with the existing lock mechanism of Windows 11. It does not alter system settings but provides a quick and effective method for users to secure their screen privacy when stepping away from their PC.