[Python] Realize never lock screen

Tip: After the article is written, the table of contents can be automatically generated. How to generate it can refer to the help document on the right


foreword

提示:这里可以添加本文要记录的大概内容:

It is mainly for the situation that the system settings never lock screen and never sleep policy do not take effect, combined with the use of Python scripts to achieve the purpose of never lock screen. The specific implementation steps are as follows:


提示:以下是本篇文章正文内容,下面案例可供参考

1. Windows side settings:

1. Operation steps (take Windows 11 as an example):

Open System Settings -> Power -> Screen and Sleep -> Set Never
insert image description here

1. Implementation steps

1. Introduce the library and code implementation, and simulate the keyboard to press the Capslock key to make the screen active.

The code is as follows (example):

import pyautogui
import time
import colortest

while True:
    #每隔5秒钟按下Capslock键
    pyautogui.press('capslock')
    time.sleep(5)

Summarize

When the lock screen policy set on the Windows side does not take effect, combined with the python script, the screen can never be locked.

Guess you like

Origin blog.csdn.net/liaotianyin/article/details/129750342