# 1、win32api模拟键盘

import win32api
import win32con
 # 输入V键
win32api.keybd_event(86, 0, 0, 0)  # enter
win32api.keybd_event(86, 0, win32con.KEYEVENTF_KEYUP, 0)
time.sleep(2)

# 输入img
img = [73, 77, 71]
for i in img:
    win32api.keybd_event(i, 0, 0, 0)  # enter
    time.sleep(0.5)
    win32api.keybd_event(i, 0, win32con.KEYEVENTF_KEYUP, 0)  # 释放按键
time.sleep(1)
# enter,enter,Y,enter
final = [13, 13, 37, 13]
for i in final:
    win32api.keybd_event(i, 0, 0, 0)  # enter
    time.sleep(0.5)
    win32api.keybd_event(i, 0, win32con.KEYEVENTF_KEYUP, 0)  # 释放按键

2、模拟鼠标操作

建议学习参考:
https://www.cnblogs.com/kongzhagen/p/6600113.html
https://www.jb51.net/article/92682.htm

链式写法
ActionChains(driver).click(clk_btn).context_click(right_btn).perform()

分步写法
# 补全化action
actions = ActionChains(driver)
# 装载单击动作
actions.click()
# 装载右击动作
actions.context_click()
# 执行所有被装载的动作
actions.perform()

方法列表

perform(self):        ---执行链中的所有动作
reset_actions(self):     ---清除存储在远端的动作
click(self, on_element=None):   ---鼠标左键单击
click_and_hold(self, on_element=None):    --鼠标左键单击,不松开
context_click(self, on_element=None):       ---鼠标右键单击
double_click(self, on_element=None):        ---鼠标左键双击
drag_and_drop(self, source, target):        ---拖拽到某个元素后松开
drag_and_drop_by_offset(self, source, xoffset, yoffset):        ---拖拽到某个坐标后松开
key_down(self, value, element=None):        ---某个键盘键被按下
key_up(self, value, element=None):          ---松开某个键
move_by_offset(self, xoffset, yoffset):     ---鼠标移动到某个坐标
move_to_element(self, to_element):          ---鼠标移动到某个元素
move_to_element_with_offset(self, to_element, xoffset, yoffset):        ---移动到距某个元素(左上角)多少的位置
release(self, on_element=None):     ---在某元素上松开鼠标
send_keys(self, *keys_to_send):     ---发送某些值到当前焦点元素
send_keys_to_element(self, element, *keys_to_send):     ---发送某些值到指定元素