使用pyautogui解锁屏幕

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

我正在使用pyautogui在Windows 10上解锁我的电脑屏幕。这是脚本:

pyautogui.FAILSAFE = False
time.sleep(7)
print("Pressing 'space'")
pyautogui.press('space')
print("Waiting for 3 seconds.")
time.sleep(3)
print("Typying Password")
pyautogui.press('p')
time.sleep(0.1)
pyautogui.press('a')
time.sleep(0.1)
pyautogui.press('s')
time.sleep(0.1)
pyautogui.press('s')
time.sleep(0.1)
pyautogui.press('w')
time.sleep(0.1)
pyautogui.press('o')
time.sleep(0.1)
pyautogui.press('r')
time.sleep(0.1)
pyautogui.press('d)
print("Hitting 'enter'")
pyautogui.press('enter')
time.sleep(9)

该脚本确实模拟了空格键,因为我的锁定屏幕被移动到它要求输入密码的屏幕,但它没有输入我的密码。我想知道为什么?当我手动打开我的帐户时,脚本的输出确认它已成功运行。可能是什么原因造成的?

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

遗憾的是,Windows专门阻止自动脚本在计算机被锁定时运行作为安全预防措施,因此您将无法向登录屏幕发送任何键盘按下。

类似的东西也适用于例如防止模拟鼠标点击或键盘按下其窗口的AV软件。这可以防止恶意软件禁用AV软件。

© www.soinside.com 2019 - 2024. All rights reserved.