How can I turn my laptop display off completely (while script is running)?
I want turn my laptops (Lenovo 100s) display off completely because I'm running a little script on it and I don't want waste energy. Because I run a script, it's not possible using Windows settings to turn the display off after specific time (as buttons are being pressed on my keybord).
I have already tried F1-F12 buttons, also with Fn button and the best result is that my screen is almost entirely black (by pressing F9). Anyway it's still visible if you take a very close look at it (use some light from lamp and hold it in front of screen, you will see it's actually still on).
Any way to do this maybe?
Solution 1:
Download and install AutoHotKey (AHK further) program.
(no any other programs needed).
Copy following AHK script and paste it to Notepad
then save file as Display-Off.ahk
.
(Make sure to choose "All files" in Notepad's "Save" dialog
when you saving file, otherwise file will be saved as Display-Off.ahk.txt
)
#m::
Sleep 1000
SendMessage, 0x112, 0xF170, 2,, Program Manager
Return
Double click on the Display-Off.ahk
saved AHK script and you done.
If you press after that Win+m key's combination you will turn display off.
If you want another hot key combinations then modify first line of AHK scrip as you liked (AutoHotKey comes with chm
help file that describes all its feature)
To turn display on, just move mouse or make a mouse click or press any key on keyboard
P.S.
If you don't want to use (IMO pretty good program ) AHK program I mentioned, then download nircmd zip archive, make a right click on this zip file and choose "Properties" from pop up menu, then in the right bottom corner click on "Unblock" button then press "Ok" and unpack nircmd.exe
file from archive.
Now, create shortcut to nircmd.exe
(make a right click on nircmd.exe
and select "Create shortcut") program and in the field target
put following string
C:\path\to\nircmd.exe cmdwait 1000 monitor off
and in the field Shortcut key
press those combination of keys that you like to turn display off. When you saved shortcut you may press chosen hot keys any time to fire up this shortcut
To compare to AutoHotKey program, creation of hot keys in shortcuts is limited, so make sure you not overriding already in use hot key's combinations.
Original answer before OP clarified that instead of shutdown he wants to turn display off only:
If you would use AutoHotKey (AHK further) program, all you need is to create AHK script like this:
#c::
Run, shutdown.exe -s -t 00
Return
Then when you run AHK and press Win+c key combination Windows will shutdown itself.
Solution 2:
Use Nircmd, a command based executable, to turn off the display:
nircmd.exe monitor off
And to turn it back on:
nircmd.exe monitor on
FYI, the download for 32/64 bit is at the bottom of the page. This utility has some cool features. You can use this program in batch or powershell scripts, or anything else.
Solution 3:
OK, lets see if I got this correctly:
- You are using a laptop and want to save energy.
- You are running a script which means that the laptop cannot be turned all the way off. It must continue to do things.
- Windows which can be configured to blank the display after X time of time. This should kick on automatically unless you are in presentation mode or unless you are actively pressing keys, actively use the mouse ect.
Based on your information I am guessing that you use a AHK script or similar which emulates this behaviour, preventing the regular blanking functionality from kicking in.
That leaves us three options:
Close the lid of the laptop. This will push a hardware switch which will disable the display (or at the very least the backlight). I've never met any laptop which could not do this. Annoyingly enough windows does ship with a setting which puts the laptop to sleep when the lid is closed (very annoying for those of use who want to walk with a laptop to a new room, or who use a laptop as a small desktop).
Luckily this can be changed in the control panel. You did not specify which version of windows you re running, so I am assuming windows 10. Which means
- Right click start,
- Left click control panel
- Dubble click "power options"
- Select "Choose what closing the lid does.
- Set this to "do nothing"Alternatively you can manually push this switch. That might require jamming a paperclick into a tine hole near the LCD and it might scratch your display if you forget to remove that when you close the lid later on. Mentioned for completeness only, though I guess you could open the laptop, trace the wires and add an hardware switch.
- The most elegant solution: Tell windows to blank the screen. I am sure there is some software for that. E.g for XP it could be done by setting the screensaver to blank the screen and then starting %SYSTEMROOT%\system32\scrnsave.scr (for which you could create a shortcut).
This part might be easier to answer after you added which version of windows you are using.