貌似就不行了,反正我的测试环境(Windows 2008 R2)是这种情况就会不行了。经过
了解,自带的解锁屏使用的服务是WINIO服务。
那好,上网找了些关于python和WINIO的资料,发现可以喔,有个库叫做pywinio的能够实现驱动层面模拟键盘输入.https
:
/ / / / / / / / / / / / / / / /那就行了,如果是停,估计就要重装设计器了
2,打开设备管理器,确保硬盘下有个叫PS标准键盘什么的东西
3,在设计器的环境中安装pywinio的库,有外网的话可以用pip来安装,python -m pip install pywinio
好了,自己写py文件,内容类似以下:至于键位对应的码参考链接:https://www.win.tu e.nl/~aeb/linux/kbd/scancodes-1.html
import pywinio
import time
import atexit
KeyBoard Commands
Command port
KBC_KEY_CMD = 0x64
Data port
KBC_KEY_DATA = 0x60
g_winio = None
def get_winio():
global g_winio
if g_winio is None:g_winio = pywinio.WinIO()def __clear_winio():global g_winiog_winio = Noneatexit.register(__clear_winio)return g_winio
def wait_for_buffer_empty():
‘’’
Wait keyboard buffer empty
‘’’
winio = get_winio()dwRegVal = 0x02
while (dwRegVal & 0x02):dwRegVal = winio.get_port_byte(KBC_KEY_CMD)
def key_down(scancode):
winio = get_winio()
wait_for_buffer_empty();
winio.set_port_byte(KBC_KEY_CMD, 0xd2);
wait_for_buffer_empty();
winio.set_port_byte(KBC_KEY_DATA, scancode)
def key_up(scancode):
winio = get_winio()
wait_for_buffer_empty();
winio.set_port_byte( KBC_KEY_CMD, 0xd2);
wait_for_buffer_empty();
winio.set_port_byte( KBC_KEY_DATA, scancode | 0x80);
def key_press(scancode, press_time = 0.2):
key_down( scancode )
time.sleep( press_time )
key_up( scancode )
Press ‘A’ key
Scancodes references : https://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html
key_press(0x1E)
102fceded8ab49e78a717fa3e7f058aa_Keyboard_Emulation.py
附件是我自己写的关于锁屏后解锁的小玩意,因为只是小尝试,所以就没考虑很全面。