上一篇介绍了pywinauto库中如何模拟鼠标操作,既然有鼠标,那么肯定有键盘。
模拟键盘操作
想要通过pywinauto模拟操作键盘,需要重新导入库 from pywinauto.keyboard import send_keys
我们想要模拟键盘操作,其实最终使用send_keys(个别朋友是不是看着特别熟悉?是不是想某地方的值?)
源码:
def send_keys(keys,
pause=0.05,
with_spaces=False,
with_tabs=False,
with_newlines=False,
turn_off_numlock=True,
vk_packet=True):
"""Parse the keys and type them"""
keys = parse_keys(
keys, with_spaces, with_tabs, with_newlines,
vk_packet=vk_packet)
for k in keys:
k.run()
time.sleep(pause)
SendKeys = deprecated(send_keys)
这里安静先简单的写了个操作流程,大家可以看看