from pynput.mouse import Controller as mouse_Control
from pynput.mouse import Button as mouse_Button
from pynput.keyboard import Controller, Key, Listener
import multiprocessing
import time
'''
create by Ruiyang : 2022/5/17
'''
# 监听按压
def on_press(key):
try:
print("正在按压:", format(key.char))
except AttributeError:
print("正在按压:", format(key))
# 监听释放
def on_release(key):
if key == Key.esc:
print(f'{"-"*40}\n监听进程结束')
# 停止监听
return False
# 开始监听
def start_listen():
with Listener(on_press=on_press, on_release=on_release) as listener:
listener.join()
def main_keyboard():
# 实例化键盘
kb = Controller()
# 开始监听,按esc退出监听
start_listen()
# 鼠标的控制函数
def mouse_click():
mouse = mouse_Control() # 获取鼠标管理员权限
mouse.click(mouse_Button.left)
# 主函数
def main(times):
print('倒计时5s,给点准备时间
Python模拟鼠标点击
最新推荐文章于 2024-09-17 21:00:47 发布