Python implements a simple function: Windows lock screen, and package it into an exe file for distribution.
(1) The lock screen program code is very simple:
from ctypes import *if __name__ == '__main__':user32 = windll.LoadLibrary('user32.dll')user32.LockWorkStation()
(2) Packaging.
Use pyinstaller.If the pyinstaller library is not installed in the current environment, pass
pip install pyinstaller
Install.After the installation is complete, the program code file of the packager entry:
The program code file where the pyinstaller main entry is located.py
If successful, a /dist folder will be generated under the project, and a folder corresponding to the file name of the corresponding code program will be generated under the folder, and the same program file name.exe inside is the final packaged executable file.