代码拉取完成,页面将自动刷新
同步操作将从 南黎/pynput库自动操作键鼠 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# @Time : 2022/8/23 7:11
# @Author : 南黎
# @FileName: 2.鼠标监听.py
# #1.鼠标移动监听
# import win32api
# import time
# from pynput.mouse import Listener, Button
#
# def mouseListener(on_move):#监听函数
# with Listener(on_move=on_move) as listener:#定义on_move回调函数用于在鼠标移动时生效
# listener.join()#添加监听器
#
# def on_move(x, y):
# timeStruct = time.localtime(int(time.time())) # 获得当前时间时间戳后转化为本地时间
# strTime = time.strftime("%Y-%m-%d %H:%M:%S", timeStruct) # 日期格式 2022-08-23 07:26:21
# print("{}鼠标坐标:{}".format(strTime,(x, y)))
# #win32api.Sleep(100) #警告:不要取消注释这一行代码。不要尝试在这入延时,否则会真的让你的鼠标移动速度变慢,你可以类比理解为降低了你的鼠标DPI
# #也许你可以用上述特性来制作一个软件用于在fps游戏中压枪·······?
# mouseListener(on_move)#调用我们写好的监听函数
#2.鼠标点击监听
# from pynput.mouse import Listener, Button
#
# def mouseListener(on_click):
# with Listener(on_click=on_click) as listener:#定义on_click回调函数用于在鼠标点击时生效
# listener.join()
#
# def on_click(x, y, button, pressed):
# print("鼠标位置为:{},执行操作为:{},是否点击或松开:{}".format((x, y), button, pressed))
#
# mouseListener(on_click)
#3.监听鼠标点击、滚动、拖动
# from pynput.mouse import Listener, Button
# from pynput import mouse
#
# def mouseListener(on_move, on_click, on_scroll):
# with Listener(on_move=on_move, on_click=on_click, on_scroll=on_scroll) as listener:
# listener.join()
# def on_move(x, y):
# pass
#
# def on_click(x, y, button, pressed):
# if button == mouse.Button.left:
# print('鼠标左键单击')
# elif button == mouse.Button.right:
# print('鼠标右键单击')
# else:
# print('鼠标滚轮按下,即将结束程序')
# print("鼠标坐标:{},鼠标操作为:{},鼠标按下弹起状态:{}".format((x, y), button, pressed))
# if button == Button.middle:
# return False
#
# #其实这里滚动监听不知道为啥有点问题,我只能监听滚轮,大家有知道的可以评论区讨论分享一下
# def on_scroll(x, y, dx, dy):
# print("鼠标位置为:{},滚轮上下滑动,1表示上滚,-1表示下滚:{}".format((x, y), (dx, dy)))
#
# mouseListener(on_move, on_click, on_scroll)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。