记录鼠标按下和松开时的坐标
像截图时的操作一样
from pynput.mouse import Button
from pynput import mouse
box = []
def on_click(x, y, button, pressed):
global box
if pressed:
# Pressed 鼠标按下
# 清空box
box = []
# print('点击')
# print(x, y)
box.append((x, y))
# print(box)
else:
# Released, 鼠标松开
box.append((x, y))
print(box)
pass
with mouse.Listener(on_click=on_click) as listener:
listener.join()