Python 记录鼠标每次点击释放坐标与时间
鼠标左键:记录当前按键的点击坐标与实践
鼠标右键:退出监听程序
import pynput
from pynput import mouse
import datetime
def on_move(x, y):
print('Pointer moved to {0}'.format((x, y)))
def on_my_click(x, y, button, pressed):
now = str(datetime.datetime.now())
if button==mouse.Button.left and pressed:
print('{0} at {1},time is {2}'.format('left Pressed',(x,y),now))
elif button==mouse.Button.right and pressed:
print('{0} at {1},time is {2}'.format('Right Pressed', (x, y),now))
return False;
with pynput.mouse.Listener(
on_click=on_my_click,
) as listener:
listener.join()