Python / Windows 10-有没有一种方法可以防止Windows 10计算机在Python中进入睡眠状态?

问题描述 投票:0回答:1

有没有一种方法可以防止Windows 10计算机在Python中进入睡眠状态?

与此处发布的问题基本相同,但对于Windows 10:Prevent OS X from going to sleep with Python?

是否可以从Python调用Windows命令?

我正在使用Python 3.6,如果有什么区别。

python python-3.x windows-10 python-3.6 sleep
1个回答
0
投票

这可能不是直接的答案,但是会起作用。您可以使用PyAutoGUI以特定的间隔单击特定的屏幕位置。这将迫使您的计算机无法进入睡眠状态

import time
import pyautogui

# press ctrl+c to get out of the loop
while(True):
    pyautogui.click(x=100, y=200) # make sure noothing is there in the clicked location
    time.sleep(10)
© www.soinside.com 2019 - 2024. All rights reserved.