web:pykeyboard、pymouse得使用
pykeyboard pymouse 是 PyInputUser类库得
安装pip install PyInputUser
依赖包:
安装依赖包地址:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyhook
from pykeyboard import PyKeyboard
from pymouse import PyMouse
key_board = PyKeyboard()
# 按i键
key_board.press_key('i')
# 放下i键
key_board.release_key('i')
# 点击K键
key_board.tap_key('k')
# 输入字符
key_board.type_string("abcdefg")
# 点击k键2次,每10秒
key_board.tap_key('k',n=2,interval=10)
# 点击F5键
key_board.tap_key(key_board.function_keys[5])
# 点击shifp键
key_board.shift_key()
mouse = PyMouse()
# 获取当前坐标得位置
mouse.position()
# 鼠标移动到 x,y位置
mouse.move(200,300)
# 鼠标移动并且在xy位置点击
mouse.click(200,300)
# 获取鼠标在屏幕中位置
mouse.screen_size()