How can I turn my laptop display off completely (while script is running)?

1

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?

cnmesr

Posted 2017-02-12T10:20:43.063

Reputation: 207

What do you mean by "window"? I am guessing that you mean the LCD screen. In which case you probably can just close the lid and it will turn the display off. (If you got that ultra annoying setting which sleeps your laptop when the lid closes, then you can fix that from control panels power options). – Hennes – 2017-02-12T10:23:53.113

@Hennes yes I mean the LCD screen. If I do this, my laptop will go standbye, I have already tried changing advanced settings there and it doesn't seem to help : / – cnmesr – 2017-02-12T10:26:31.433

Not sure if lenovo has it but on my dell I can hit fn + b to enable lights out mode. It turns all light and sound off. I think I had to enable it in the bios though. – birdman3131 – 2017-02-12T11:17:30.047

Request for someone to remove the choice of this as answer because I asked same question and got marked as a duplicate... – Ahmed – 2018-09-20T03:41:52.397

Answers

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.

Alex

Posted 2017-02-12T10:20:43.063

Reputation: 5 606

1I suspect his script will stop running after you shut down windows. – Hennes – 2017-02-12T11:24:34.580

@Hennes Of cause it does, but that was requirement in original question (before it was edited) - turn computer off, which apply shutdown. Now I see OP wanted to turn off display only...Duh.. – Alex – 2017-02-12T11:27:48.637

1Yeah, it was pretty confusing. Hence my questions to OP and the edit. – Hennes – 2017-02-12T11:28:47.680

3

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.

Keltari

Posted 2017-02-12T10:20:43.063

Reputation: 57 019

1nircmd.exe monitor on not needed, any mouse click or pressing any key will wake up monitor – Alex – 2017-02-12T11:44:39.323

1

OK, lets see if I got this correctly:

  1. You are using a laptop and want to save energy.
  2. You are running a script which means that the laptop cannot be turned all the way off. It must continue to do things.
  3. 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:

  1. 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"

  2. 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.

  3. 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.

Hennes

Posted 2017-02-12T10:20:43.063

Reputation: 60 739

1

All the other answers here use extra software. If you don't want to do this, there's a much simpler method: Set the power button pressed action to turn off the screen. This means if you ever want to turn off the display all you have to do is press the power button.

1) Open control panel and go to power options. Then click "choose what the power button does" enter image description here

2) Change the "When I press the power button" option to "Turn off the display" for both battery and plugged in, and hit save changes. enter image description here

You should now be able to hit the power button and have the display turn off. You can wake it by simply pressing a key or moving the mouse. Depending on exactly how your script is configured, the display may wake again from script key presses, making this not a good solution for your exact case, but it should work.

Blaine

Posted 2017-02-12T10:20:43.063

Reputation: 1 477

1

I asked the same question and I don't have a conclusive answer but in some of my scripts the solution to have the LCD off and still have my screen off was... drum roll please... Close the laptop.

Subsequently, purely keyboard based scripts will definitely run. GUI / mouse operations may have problem especially those with pixel/image detection.

Games that require your screen to be off will definitely cause a fuss.

Anyway, no conclusive answer but I think this is the closest we have to an answer as of this writing...

Ahmed

Posted 2017-02-12T10:20:43.063

Reputation: 243

0

I recently wrote this app to have the option to turn off the screen of my laptop with just one click or press a hotkey.

The only flaw is, it requires Powershell.

Dr RedAnt

Posted 2017-02-12T10:20:43.063

Reputation: 84