鼠标手辅助器

news/2024/11/30 5:58:59/

鼠标发生移动后 ,静止在某位置指定时间后即可触发点击事件
支持多种点击事件,支持快捷键触发,支持自定义配置

有其他更好的思路 ,支持有偿定制,留言留下联系方式,看到会加你

python"># !/usr/bin/python3
# -*- coding:utf-8 -*-
"""
@author: JHC000abc@gmail.com
@file: test.py
@time: 2024/4/11 0:04
@desc:"""
import pyautogui
import keyboard
import time
from threading import Thread
import atexitclass MouseClick(object):""""""def __init__(self,time_click_interval):atexit.register(self.exit_handler)# 位置收集开关self.flag_open_close = True# 点击间隔self.time_click_interval = time_click_interval# 点击模式self.click_mode = 1# 此处静止 点击过self.forbidden = Falseself.thread = Thread(target=self.monitor_keyboard)self.thread.start()def exit_handler(self):"""程序退出自动执行:return:"""input("\n\n\n程序终止,回车退出")def monitor_keyboard(self):""":return:"""keyboard.on_press(self.on_combination_pressed_click)keyboard.on_press(self.on_combination_pressed_doubleClick)keyboard.on_press(self.on_combination_pressed_tripleClick)keyboard.on_press(self.on_combination_pressed_down)keyboard.on_press(self.on_combination_pressed_pause)keyboard.on_press(self.on_combination_pressed_click_right)keyboard.wait('esc')def monitor_mouse_move(self, x, y):""":param x::param y::return:"""if self.flag_open_close:if self.click_mode == 1:pyautogui.click(x, y)print(f"单击:x:{x}, y:{y}")elif self.click_mode == 2:pyautogui.doubleClick(x, y)print(f"双击:x:{x}, y:{y}")elif self.click_mode == 3:pyautogui.tripleClick(x, y)print(f"三击:x:{x}, y:{y}")elif self.click_mode == 4:pyautogui.rightClick(x, y)print(f"右键单击:x:{x}, y:{y}")def on_combination_pressed_pause(self,event):"""单击:param event::return:"""if keyboard.is_pressed('ctrl') and keyboard.is_pressed('`'):if self.flag_open_close:self.flag_open_close = Falseprint("【暂停】:ctrl+`")else:self.flag_open_close = Trueprint("【开启】:ctrl+`")def on_combination_pressed_click(self,event):"""单击:param event::return:"""if keyboard.is_pressed('ctrl') and keyboard.is_pressed('shift') and keyboard.is_pressed('1'):self.click_mode = 1print("【单击模式】:ctrl+shift+1")def on_combination_pressed_click_right(self,event):"""单击:param event::return:"""if keyboard.is_pressed('tab'):self.click_mode = 4print("【右键单击模式】:tab")def on_combination_pressed_doubleClick(self,event):"""双击:param event::return:"""if keyboard.is_pressed('ctrl') and keyboard.is_pressed('shift') and keyboard.is_pressed('2'):self.click_mode = 2print("【双击模式】:ctrl+shift+2")def on_combination_pressed_tripleClick(self,event):"""三击:param event::return:"""if keyboard.is_pressed('ctrl') and keyboard.is_pressed('shift') and keyboard.is_pressed('3'):self.click_mode = 3print("【三击模式】:ctrl+shift+3")def on_combination_pressed_down(self,event):"""长按 可拖动窗体:param event::return:"""if keyboard.is_pressed('alt'):pyautogui.mouseDown()print("【左键长按模式】:alt")def process(self):""":return:"""print("鼠标手辅助器 启动")print("点击间隔:",self.time_click_interval )prev_x, prev_y = pyautogui.position()while True:try:current_x, current_y = pyautogui.position()if current_x != prev_x or current_y != prev_y:prev_x, prev_y = current_x, current_yelse:start_time = time.time()while True:new_x, new_y = pyautogui.position()if new_x != current_x or new_y != current_y:self.forbidden = Falsebreakif time.time() - start_time >= self.time_click_interval:if not self.forbidden:self.monitor_mouse_move(new_x, new_y)self.forbidden = Truebreakif keyboard.is_pressed("esc"):print("【退出】ESC")breakexcept Exception as e:print("【错误】:请勿将鼠标移动到边缘区域")if __name__ == '__main__':time_click_interval = input("请输入点击间隔时间(单位:秒):")# time_click_interval = 3mc = MouseClick(float(time_click_interval))mc.process()

http://www.ppmy.cn/news/1431245.html

相关文章

hadoop安装记录

零、版本说明 centos [rootnode1 ~]# cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core)jdk [rootnode1 ~]# java -version java version "1.8.0_311" Java(TM) SE Runtime Environment (build 1.8.0_311-b11) Java HotSpot(TM) 64-Bit Server VM (…

【数据结构】单链表的尾插法

尾插法是一种在链表末尾插入新元素的方法,它的核心思想是保持链表的尾部指针(或称为尾节点),这样可以在常数时间内完成尾部插入操作。尾插法的主要步骤如下: 创建新节点:首先,根据需要插入的数据…

lazarus-ide简介

Lazarus是一个集成开发环境(IDE),专为使用Free Pascal编译器的Pascal语言设计。它支持快速应用开发(RAD),允许开发者创建跨平台的图形用户界面(GUI)应用程序。以下是关于Lazarus的来…

鸿蒙 harmonyos 线程 并发 总结 async promise Taskpool woker(三)多线程并发 Worker

Worker Worker是与主线程并行的独立线程。创建Worker的线程称之为宿主线程,Worker自身的线程称之为Worker线程。创建Worker传入的url文件在Worker线程中执行,可以处理耗时操作但不可以直接操作UI。 Worker主要作用是为应用程序提供一个多线程的运行环境…

AI检索增强生成引擎-RAGFlow-深度理解知识文档,提取真知灼见

💡 RAGFlow 是什么? RAGFlow是一款基于深度文档理解构建的开源RAG(Retrieval-Augmented Generation)引擎。RAGFlow个人可以为各种规模的企业及提供一套专业的RAG工作流程,结合针对用户群体的大语言模型(LL…

力扣经典150题第三十五题:螺旋矩阵

目录 力扣经典150题第三十五题:螺旋矩阵引言题目详解解题思路代码实现示例演示复杂度分析总结扩展阅读 力扣经典150题第三十五题:螺旋矩阵 引言 本篇博客介绍了力扣经典150题中的第三十五题:螺旋矩阵。题目要求按照顺时针螺旋顺序遍历给定的…

华纳云:怎么防止租用服务器的数据丢失?

要防止租用服务器上的数据丢失,可以采取以下一些措施: 定期备份数据:建立定期备份数据的机制,将重要数据备份到安全的地方,例如云存储服务、外部硬盘或者另一个服务器上。备份频率可以根据数据的重要性和变动频率来确定…

[Kotlin]引导页

使用Kotlin Jetpack Compose创建一个左右滑动的引导页, 效果如图. 1.添加依赖项 androidx.compose.ui最新版本查询:https://maven.google.com/web/index.html com.google.accompanist:accompanist-pager最新版本查询:https://central.sonatype.com/ 确保在 build.gradle (M…