使用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)
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 软件。

最新更新