Python 3.x 使用pyautogui解锁屏幕

Python 3.x 使用pyautogui解锁屏幕,python-3.x,windows-10,pyautogui,Python 3.x,Windows 10,Pyautogui,我正在使用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) pyautogu

我正在使用
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)

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

不幸的是,作为安全预防措施,Windows特别禁止在计算机锁定时运行自动脚本,因此您将无法向登录屏幕发送任何键盘按键

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