Monday, 14 May 2018

windows - 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?



Answer



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.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...