简体   繁体   中英

Unlock Windows using Python Keyboard

I am using python keyboard lib to unlock my windows desktop, when I try

keyboard.send('win+l')

It print l in my screen but not lock my computer

later I using ctypes.windll.lockworkstation() to lock my computer, but when I want to control my keyboard to unlock my computer, It dosen't work, so how should I fix this problem

below is my code now,I using python36/win10

import ctypes,time,keyboard
dll = ctypes.WinDLL('user32.dll')
dll.LockWorkStation()
time.sleep(1)
keyboard.send('enter')
keyboard.send('1,2,3')
keyboard.send('enter')

For anyone still looking for a solution, there is none (in python)

Both unfortunately and fortunately, Windows blocks software keyboard input in the passcode/password screen to prevent automated scripts from controlling the PC. The few ways you can unlock Windows programmatically, is to either emulate a physical keyboard, or use a lower-level language such as C, C++ or C#

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM