Reputation: 49
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')
Upvotes: 3
Views: 3706
Reputation: 81
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#
Upvotes: 1