Personalization Add "Turn off display" Context Menu in Windows 11


  • Staff
Display_banner.png

This tutorial will show you how to add a Turn off display desktop context menu that will let users Turn off display or Lock computer and Turn off display on demand in Windows 10 and Windows 11.

By default, You can specify a screen timeout for how long the PC sits inactive without user activity before all connected displays automatically turn off.

When your display turns off, you would just need to move the mouse, touch the touchpad or touchscreen, click a mouse or touchpad button, or press a key for the display(s) to turn back on.

There may be times when you would like to turn off the display or lock computer and turn off display on demand instead.


While you must be signed in as an administrator to add or remove the "Turn off display" context menu, all users will be able to use the context menu.


Using this context menu will leave a command prompt window open that you will need to manually close when you resume.




Contents

  • Option One: Add "Turn off display" to Desktop Context Menu
  • Option Two: Remove "Turn off display" from Desktop Context Menu


EXAMPLE: "Turn off display" desktop context menu

It is required to click/tap on Show more options first by default, then click/tap on Turn off display.


Show_more_options.png
Turn_off_display_context_menu.png





Option One

Add "Turn off display" to Desktop Context Menu


1 Click/tap on the Download button below to download the REG file below.

Add_Turn_off_display_to_desktop_context_menu.reg


(Contents of REG file for reference)
Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\TurnOffDisplay]
"Icon"="imageres.dll,-109"
"MUIVerb"="Turn off display"
"Position"="Bottom"
"SubCommands"=""

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\TurnOffDisplay\shell]

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\TurnOffDisplay\shell\01menu]
"Icon"="powercpl.dll,-513"
"MUIVerb"="Turn off display"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\TurnOffDisplay\shell\01menu\command]
@="cmd /c \"powershell.exe -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)\"\""

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\TurnOffDisplay\shell\02menu]
"MUIVerb"="Lock computer and Turn off display"
"CommandFlags"=dword:00000020
"Icon"="imageres.dll,-59"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\TurnOffDisplay\shell\02menu\command]
@="cmd /c \"powershell.exe -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)\" & rundll32.exe user32.dll, LockWorkStation\""

2 Save the .reg file to your desktop.

3 Double click/tap on the downloaded .reg file to merge it.

4 When prompted, click/tap on Run, Yes (UAC), Yes, and OK to approve the merge.

5 You can now delete the downloaded .reg file if you like.




Option Two

Remove "Turn off display" from Desktop Context Menu


1 Click/tap on the Download button below to download the REG file below.

Remove_Turn_off_display_from_desktop_context_menu.reg


(Contents of REG file for reference)
Code:
Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\DesktopBackground\Shell\TurnOffDisplay]

2 Save the .reg file to your desktop.

3 Double click/tap on the downloaded .reg file to merge it.

4 When prompted, click/tap on Run, Yes (UAC), Yes, and OK to approve the merge.

5 You can now delete the downloaded .reg file if you like.


That's it,
Shawn Brink


 

Attachments

  • Display.png
    Display.png
    7.6 KB · Views: 94
  • Remove_Turn_off_display_from_desktop_context_menu.reg
    518 bytes · Views: 77
  • Add_Turn_off_display_to_desktop_context_menu.reg
    2.7 KB · Views: 118
Last edited:
Try running the reg patch again.
I already did two times or so.

Although I don't understand the different Windows language thing... that could be the problem?
Sorry, what could be the problem? The language? With the reg entry?
 

My Computer

System One

  • OS
    Win 11
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo IdeaPad 3 17ABA7 Laptop - Type 82RQ (Lenovo IdeaPad 3 82RQ003EGE)
    Memory
    16 GB
@Brink

There's something wrong with those reg patches.

The "remove" reg patch works fine.
The "add" reg patch sort of works.

When I click "turn off display", a blank power shell window opens and the display goes off. But in about 3-4 seconds it comes back on.



/edit

I checked and the new reg patches didn't affect the nircmd.exe in System32, so... I just ran the new "remove" reg patch, then ran the Windows 10 tutorial reg patch again... and the "Turn off display" works again.
 

My Computers

System One System Two

  • OS
    Win 11 Home ♦♦♦22631.3527 ♦♦♦♦♦♦♦23H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Built by Ghot® [May 2020]
    CPU
    AMD Ryzen 7 3700X
    Motherboard
    Asus Pro WS X570-ACE (BIOS 4702)
    Memory
    G.Skill (F4-3200C14D-16GTZKW)
    Graphics Card(s)
    EVGA RTX 2070 (08G-P4-2171-KR)
    Sound Card
    Realtek ALC1220P / ALC S1220A
    Monitor(s) Displays
    Dell U3011 30"
    Screen Resolution
    2560 x 1600
    Hard Drives
    2x Samsung 860 EVO 500GB,
    WD 4TB Black FZBX - SATA III,
    WD 8TB Black FZBX - SATA III,
    DRW-24B1ST CD/DVD Burner
    PSU
    PC Power & Cooling 750W Quad EPS12V
    Case
    Cooler Master ATCS 840 Tower
    Cooling
    CM Hyper 212 EVO (push/pull)
    Keyboard
    Ducky DK9008 Shine II Blue LED
    Mouse
    Logitech Optical M-100
    Internet Speed
    300/300
    Browser
    Firefox (latest)
    Antivirus
    Bitdefender Internet Security
    Other Info
    Speakers: Klipsch Pro Media 2.1
  • Operating System
    Windows XP Pro 32bit w/SP3
    Computer type
    PC/Desktop
    Manufacturer/Model
    Built by Ghot® (not in use)
    CPU
    AMD Athlon 64 X2 5000+ (OC'd @ 3.2Ghz)
    Motherboard
    ASUS M2N32-SLI Deluxe Wireless Edition
    Memory
    TWIN2X2048-6400C4DHX (2 x 1GB, DDR2 800)
    Graphics card(s)
    EVGA 256-P2-N758-TR GeForce 8600GT SSC
    Sound Card
    Onboard
    Monitor(s) Displays
    ViewSonic G90FB Black 19" Professional (CRT)
    Screen Resolution
    up to 2048 x 1536
    Hard Drives
    WD 36GB 10,000rpm Raptor SATA
    Seagate 80GB 7200rpm SATA
    Lite-On LTR-52246S CD/RW
    Lite-On LH-18A1P CD/DVD Burner
    PSU
    PC Power & Cooling Silencer 750 Quad EPS12V
    Case
    Generic Beige case, 80mm fans
    Cooling
    ZALMAN 9500A 92mm CPU Cooler
    Mouse
    Logitech Optical M-BT96a
    Keyboard
    Logitech Classic Keybooard 200
    Internet Speed
    300/300
    Browser
    Firefox 3.x ??
    Antivirus
    Symantec (Norton)
    Other Info
    Still assembled, still runs. Haven't turned it on for 13 years?
You might have to temporarily set Windows to English...
Would that be that easy to do?

What might be in the reg entry that might work dependently from languages? Actually I - without having any idea of anything - would think all program code is english in Win, could not imagine that would cause any problems because of the language.

I honestly don't know what happens to the registry when the Windows language changes.
It would have been good if I had known earlier. But if the computer will start again next time....
 

My Computer

System One

  • OS
    Win 11
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo IdeaPad 3 17ABA7 Laptop - Type 82RQ (Lenovo IdeaPad 3 82RQ003EGE)
    Memory
    16 GB
If you moved the mouse after clicking on it, it may cause that to happen.


Yep. I must have bumped the computer desk.
Just rechecked it... and the "new" method works.

I'm still gonna use the "old" method, cause I don't like seeing that blank power shell window. :-)
I'm gonna put both methods in the Leader Board.
 

My Computers

System One System Two

  • OS
    Win 11 Home ♦♦♦22631.3527 ♦♦♦♦♦♦♦23H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Built by Ghot® [May 2020]
    CPU
    AMD Ryzen 7 3700X
    Motherboard
    Asus Pro WS X570-ACE (BIOS 4702)
    Memory
    G.Skill (F4-3200C14D-16GTZKW)
    Graphics Card(s)
    EVGA RTX 2070 (08G-P4-2171-KR)
    Sound Card
    Realtek ALC1220P / ALC S1220A
    Monitor(s) Displays
    Dell U3011 30"
    Screen Resolution
    2560 x 1600
    Hard Drives
    2x Samsung 860 EVO 500GB,
    WD 4TB Black FZBX - SATA III,
    WD 8TB Black FZBX - SATA III,
    DRW-24B1ST CD/DVD Burner
    PSU
    PC Power & Cooling 750W Quad EPS12V
    Case
    Cooler Master ATCS 840 Tower
    Cooling
    CM Hyper 212 EVO (push/pull)
    Keyboard
    Ducky DK9008 Shine II Blue LED
    Mouse
    Logitech Optical M-100
    Internet Speed
    300/300
    Browser
    Firefox (latest)
    Antivirus
    Bitdefender Internet Security
    Other Info
    Speakers: Klipsch Pro Media 2.1
  • Operating System
    Windows XP Pro 32bit w/SP3
    Computer type
    PC/Desktop
    Manufacturer/Model
    Built by Ghot® (not in use)
    CPU
    AMD Athlon 64 X2 5000+ (OC'd @ 3.2Ghz)
    Motherboard
    ASUS M2N32-SLI Deluxe Wireless Edition
    Memory
    TWIN2X2048-6400C4DHX (2 x 1GB, DDR2 800)
    Graphics card(s)
    EVGA 256-P2-N758-TR GeForce 8600GT SSC
    Sound Card
    Onboard
    Monitor(s) Displays
    ViewSonic G90FB Black 19" Professional (CRT)
    Screen Resolution
    up to 2048 x 1536
    Hard Drives
    WD 36GB 10,000rpm Raptor SATA
    Seagate 80GB 7200rpm SATA
    Lite-On LTR-52246S CD/RW
    Lite-On LH-18A1P CD/DVD Burner
    PSU
    PC Power & Cooling Silencer 750 Quad EPS12V
    Case
    Generic Beige case, 80mm fans
    Cooling
    ZALMAN 9500A 92mm CPU Cooler
    Mouse
    Logitech Optical M-BT96a
    Keyboard
    Logitech Classic Keybooard 200
    Internet Speed
    300/300
    Browser
    Firefox 3.x ??
    Antivirus
    Symantec (Norton)
    Other Info
    Still assembled, still runs. Haven't turned it on for 13 years?
@Brink

There's something wrong with those reg patches.

The "remove" reg patch works fine.
The "add" reg patch sort of works.

When I click "turn off display", a blank power shell window opens and the display goes off. But in about 3-4 seconds it comes back on.



/edit

I checked and the new reg patches didn't affect the nircmd.exe in System32, so... I just ran the new "remove" reg patch, then ran the Windows 10 tutorial reg patch again... and the "Turn off display" works again.

I've update the REG again to wrap the new command with cmd. It seems to have solved the issue with the display turning back on shortly afterwards.

Please try the new REG to see if you see the same.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro for Workstations
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom self build
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING (11GB GDDR5X)
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G75 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3 wall mounted
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gbps Download and 35 Mbps Upload
    Browser
    Google Chrome
    Antivirus
    Microsoft Defender and Malwarebytes Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    APC SMART-UPS RT 1000 XL - SURT1000XLI,
    Galaxy S23 Plus phone
  • Operating System
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    HP Spectre x360 2in1 14-eu0098nr (2024)
    CPU
    Intel Core Ultra 7 155H 4.8 GHz
    Memory
    16 GB LPDDR5x-7467 MHz
    Graphics card(s)
    Integrated Intel Arc
    Sound Card
    Poly Studio
    Monitor(s) Displays
    14" 2.8K OLED multitouch
    Screen Resolution
    2880 x 1800
    Hard Drives
    2 TB PCIe NVMe M.2 SSD
    Internet Speed
    Intel Wi-Fi 7 BE200 (2x2) and Bluetooth 5.4
    Browser
    Chrome and Edge
    Antivirus
    Windows Defender and Malwarebytes Premium
I've update the REG again to wrap the new command with cmd. It seems to have solved the issue with the display turning back on shortly afterwards.

Please try the new REG to see if you see the same.


See above. It works. I just retested it.
I'm still using the old way though. :cool:
 

My Computers

System One System Two

  • OS
    Win 11 Home ♦♦♦22631.3527 ♦♦♦♦♦♦♦23H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Built by Ghot® [May 2020]
    CPU
    AMD Ryzen 7 3700X
    Motherboard
    Asus Pro WS X570-ACE (BIOS 4702)
    Memory
    G.Skill (F4-3200C14D-16GTZKW)
    Graphics Card(s)
    EVGA RTX 2070 (08G-P4-2171-KR)
    Sound Card
    Realtek ALC1220P / ALC S1220A
    Monitor(s) Displays
    Dell U3011 30"
    Screen Resolution
    2560 x 1600
    Hard Drives
    2x Samsung 860 EVO 500GB,
    WD 4TB Black FZBX - SATA III,
    WD 8TB Black FZBX - SATA III,
    DRW-24B1ST CD/DVD Burner
    PSU
    PC Power & Cooling 750W Quad EPS12V
    Case
    Cooler Master ATCS 840 Tower
    Cooling
    CM Hyper 212 EVO (push/pull)
    Keyboard
    Ducky DK9008 Shine II Blue LED
    Mouse
    Logitech Optical M-100
    Internet Speed
    300/300
    Browser
    Firefox (latest)
    Antivirus
    Bitdefender Internet Security
    Other Info
    Speakers: Klipsch Pro Media 2.1
  • Operating System
    Windows XP Pro 32bit w/SP3
    Computer type
    PC/Desktop
    Manufacturer/Model
    Built by Ghot® (not in use)
    CPU
    AMD Athlon 64 X2 5000+ (OC'd @ 3.2Ghz)
    Motherboard
    ASUS M2N32-SLI Deluxe Wireless Edition
    Memory
    TWIN2X2048-6400C4DHX (2 x 1GB, DDR2 800)
    Graphics card(s)
    EVGA 256-P2-N758-TR GeForce 8600GT SSC
    Sound Card
    Onboard
    Monitor(s) Displays
    ViewSonic G90FB Black 19" Professional (CRT)
    Screen Resolution
    up to 2048 x 1536
    Hard Drives
    WD 36GB 10,000rpm Raptor SATA
    Seagate 80GB 7200rpm SATA
    Lite-On LTR-52246S CD/RW
    Lite-On LH-18A1P CD/DVD Burner
    PSU
    PC Power & Cooling Silencer 750 Quad EPS12V
    Case
    Generic Beige case, 80mm fans
    Cooling
    ZALMAN 9500A 92mm CPU Cooler
    Mouse
    Logitech Optical M-BT96a
    Keyboard
    Logitech Classic Keybooard 200
    Internet Speed
    300/300
    Browser
    Firefox 3.x ??
    Antivirus
    Symantec (Norton)
    Other Info
    Still assembled, still runs. Haven't turned it on for 13 years?
Would that be that easy to do?

What might be in the reg entry that might work dependently from languages? Actually I - without having any idea of anything - would think all program code is english in Win, could not imagine that would cause any problems because of the language.


It would have been good if I had known earlier. But if the computer will start again next time....



I don't know if it's easy or not.
I don't know if it's necessary or not. I'm just guessing here.

I would think that no matter what language Windows is in... the Registry stays in English... but I don't know for sure.


It looks like your Windows is in... German?
Open the registry and see if the registry is in German or English.

Right click START and choose: Run
Type regedit.exe in the Run box and click OK.


It must not make a difference. If it did, someone would have noticed it by now.
 
Last edited:

My Computers

System One System Two

  • OS
    Win 11 Home ♦♦♦22631.3527 ♦♦♦♦♦♦♦23H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Built by Ghot® [May 2020]
    CPU
    AMD Ryzen 7 3700X
    Motherboard
    Asus Pro WS X570-ACE (BIOS 4702)
    Memory
    G.Skill (F4-3200C14D-16GTZKW)
    Graphics Card(s)
    EVGA RTX 2070 (08G-P4-2171-KR)
    Sound Card
    Realtek ALC1220P / ALC S1220A
    Monitor(s) Displays
    Dell U3011 30"
    Screen Resolution
    2560 x 1600
    Hard Drives
    2x Samsung 860 EVO 500GB,
    WD 4TB Black FZBX - SATA III,
    WD 8TB Black FZBX - SATA III,
    DRW-24B1ST CD/DVD Burner
    PSU
    PC Power & Cooling 750W Quad EPS12V
    Case
    Cooler Master ATCS 840 Tower
    Cooling
    CM Hyper 212 EVO (push/pull)
    Keyboard
    Ducky DK9008 Shine II Blue LED
    Mouse
    Logitech Optical M-100
    Internet Speed
    300/300
    Browser
    Firefox (latest)
    Antivirus
    Bitdefender Internet Security
    Other Info
    Speakers: Klipsch Pro Media 2.1
  • Operating System
    Windows XP Pro 32bit w/SP3
    Computer type
    PC/Desktop
    Manufacturer/Model
    Built by Ghot® (not in use)
    CPU
    AMD Athlon 64 X2 5000+ (OC'd @ 3.2Ghz)
    Motherboard
    ASUS M2N32-SLI Deluxe Wireless Edition
    Memory
    TWIN2X2048-6400C4DHX (2 x 1GB, DDR2 800)
    Graphics card(s)
    EVGA 256-P2-N758-TR GeForce 8600GT SSC
    Sound Card
    Onboard
    Monitor(s) Displays
    ViewSonic G90FB Black 19" Professional (CRT)
    Screen Resolution
    up to 2048 x 1536
    Hard Drives
    WD 36GB 10,000rpm Raptor SATA
    Seagate 80GB 7200rpm SATA
    Lite-On LTR-52246S CD/RW
    Lite-On LH-18A1P CD/DVD Burner
    PSU
    PC Power & Cooling Silencer 750 Quad EPS12V
    Case
    Generic Beige case, 80mm fans
    Cooling
    ZALMAN 9500A 92mm CPU Cooler
    Mouse
    Logitech Optical M-BT96a
    Keyboard
    Logitech Classic Keybooard 200
    Internet Speed
    300/300
    Browser
    Firefox 3.x ??
    Antivirus
    Symantec (Norton)
    Other Info
    Still assembled, still runs. Haven't turned it on for 13 years?
Yes, I understand.

German, yes.

The music goes on playing on an external amp via HDMI when "Option One" works?
 

My Computer

System One

  • OS
    Win 11
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo IdeaPad 3 17ABA7 Laptop - Type 82RQ (Lenovo IdeaPad 3 82RQ003EGE)
    Memory
    16 GB
, cause I don't like seeing that blank power shell window. :-)
Here's an easy fix. Paste the code below in notepad and save it as a new textfile. Rename the .txt extension of the file to .cs (e.g., ScreenOff.cs).
Code:
using System.Runtime.InteropServices;
class Program
{
   [DllImport("user32.dll")]
   private static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);
   static void Main(string[] args)
   {
      System.Threading.Thread.Sleep(2000);
      SendMessage(0xFFFF,0x112,0xF170,2);
   }
}
In the same folder, create a new batchfile (e.g., build_ScreenOff.bat)
Code:
@ECHO OFF
FOR /F "tokens=* USEBACKQ" %%F IN (`REG QUERY "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" /v InstallPath`) DO SET InstallPath=%%F
SET InstallPath=%InstallPath:*REG_SZ =%
FOR /F "tokens=* Eol= " %%F IN ("%InstallPath%") DO SET "InstallPath=%%F"
IF EXIST "%InstallPath%csc.exe" ("%InstallPath%csc.exe" /out:"%~dp0\ScreenOff.exe" /target:winexe "%~dp0\ScreenOff.cs") ELSE (ECHO ERROR - Missing csc.exe)
PAUSE
It will use the C# compiler (that is a part of the .NET Framework, which comes installed on Windows 11 by default) to create an .exe file (e.g., ScreenOff.exe). The rest should be trivial.

Note: System.Threading.Thread.Sleep(2000); causes an initial delay of 2 seconds, this is so that any mouse movement that may result from letting go of the mouse within 2 seconds after you clicked on "Turn off display" doesn't cause the display to wake right up again.
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
Sorry to necro an old post, but I just applied this tweak and it works fine, however it seems to leave the command prompt window open after running, and I need to close it every time after waking my displays. It's a minor annoyance but is there any way to force close the window after, like adding some kind of exit command?
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom
    CPU
    AMD Ryzen 9 5900x
    Motherboard
    MSI MPG x570 Gaming Plus
    Memory
    16GB DDR4-3466 MHz
    Graphics Card(s)
    NVIDIA GeForce RTX 3080ti
    Monitor(s) Displays
    MSI Optix MAG27CQ
    Screen Resolution
    1440p
    Hard Drives
    Samsung 970 EVO Plus NVMe 250GB
    Crucial P1 NVMe 1TB
    Western Digital WD Red 3TB
    PSU
    CORSAIR HX850
    Case
    NZXT H710i
    Cooling
    Cooler Master MasterLiquid ML240L
    Internet Speed
    1000/30
Is there perhaps a way to use the tweak without switching off the music on the external amplifier?
 

My Computer

System One

  • OS
    Win 11
    Computer type
    Laptop
    Manufacturer/Model
    Lenovo IdeaPad 3 17ABA7 Laptop - Type 82RQ (Lenovo IdeaPad 3 82RQ003EGE)
    Memory
    16 GB
Sorry to necro an old post, but I just applied this tweak and it works fine, however it seems to leave the command prompt window open after running, and I need to close it every time after waking my displays. It's a minor annoyance but is there any way to force close the window after, like adding some kind of exit command?
Yeah. That's why I offered a solution in the post directly above yours.
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
Is there a way to implement the "lock computer and turn off display" function as an executable so that I can use it via a shortcut and apply it by a keyboard combination? Similar to how Win + L locks the computer, I'd like a way to simply do something like that to both lock the computer and turn off the display, if possible.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
Is there a way to implement the "lock computer and turn off display" function as an executable so that I can use it via a shortcut and apply it by a keyboard combination? Similar to how Win + L locks the computer, I'd like a way to simply do something like that to both lock the computer and turn off the display, if possible.
Lock_computer_and_ScreenOff.cs
Code:
using System.Runtime.InteropServices;
class Program
{
   [DllImport("user32.dll")]
   private static extern bool LockWorkStation();

   [DllImport("user32.dll")]
   private static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);

   static void Main(string[] args)
   {
      LockWorkStation();
      System.Threading.Thread.Sleep(2000);
      SendMessage(0xFFFF,0x112,0xF170,2);
   }
}

Build Lock_computer_and_ScreenOff.bat
Batch:
@ECHO OFF
FOR /F "tokens=* USEBACKQ" %%F IN (`REG QUERY "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" /v InstallPath`) DO SET "InstallPath=%%F"
SET InstallPath=%InstallPath:*REG_SZ =%
FOR /F "tokens=* Eol= " %%F IN ("%InstallPath%") DO SET "InstallPath=%%F"
IF EXIST "%InstallPath%csc.exe" ("%InstallPath%csc.exe" /out:"%~dp0\Lock_computer_and_ScreenOff.exe" /target:winexe "%~dp0\Lock_computer_and_ScreenOff.cs") ELSE (ECHO ERROR - Missing csc.exe)
PAUSE

To unlock the computer, you do not need to wake the screen up again first. Instead, you can just immediately start typing in your PIN code, as the screen will automatically turn back on after you start typing.
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF

Latest Support Threads

Back
Top Bottom