Now many companies need to consider energy saving, especially on electricity energy. So many companies are management of computers, such as when you leave the computer, you need to put the monitor off, while keeping the computer locked, so as to help save energy, but also can prolong the life of the computer monitor, but also can keep your content confidential, do not let unrelated people see the relevant information, and may mistakenly manipulate your valuable information.
Using the display's physical buttons to turn off the display before using this feature program will cause the button to malfunction and speed up the display's damage by pressing more times. In addition, you need to press the shortcut key to the desktop lock, so there is a little more operation. Use the following script program, you can click, that can be two functions, more convenient and quick.
The code is as follows:
#python 3.4 win7from ctypes import *from ctypes.wintypes Import *hwnd_broadcast = 0xffffwm_syscommand = 0x0112sc_monitorpo WER = 0xf170monitorpoweroff = 2sw_show = 5def Main (): Windll.user32.PostMessageW (Hwnd_broadcast, Wm_syscommand, Sc_monitorpower, Monitorpoweroff) Shell32 = Windll. LoadLibrary ("Shell32.dll"); Shell32. Shellexecutew (None, ' open ', ' rundll32.exe ', ' user32,lockworkstation ', ' sw_show ') if __name__ = = "__main__": Print ("Win32 application in Python") Main ()
Cai Junsheng qq:9073204 Shenzhen
Use Python to quickly turn your display off and lock your desktop