连点器 您所在的位置:网站首页 python制作鼠标连点器 连点器

连点器

#连点器| 来源: 网络整理| 查看: 265

全民制作人们大家好,大学牲和G哥合作,一起写了一个鼠标可视化的连点器!

请注意,如果报错自行网上搜索,大概率是库文件的确实,自行百度,使用pip安装相关的库文件就可以解决,自己解决不了再问我

个人加了点料(也就是显示图片的功能,显示的猫猫头),即使这个图片不存在也是可以运行的!

来看代码(完整代码):

from pynput.mouse import Button, Controller from PIL import ImageTk, Image import time import os import tkinter as tk mouse = Controller() def click_left_button(duration): time.sleep(1) end_time = time.time() + duration while time.time() < end_time: mouse.press(Button.left) mouse.release(Button.left) time.sleep(0.01) # 可根据需要调整点击间隔时间 print("鼠标左键执行完毕") def click_right_button(duration): time.sleep(1) end_time = time.time() + duration while time.time() < end_time: mouse.press(Button.right) mouse.release(Button.right) time.sleep(0.01) # 可根据需要调整点击间隔时间 print("鼠标右键执行完毕") def mr(): a1=int(entry1.get()) click_right_button(1) click_right_button(a1) result_label.config(text="成功执行了"+str(a1)+"秒") def ml(): a1=int(entry1.get()) click_left_button(a1) result_label.config(text="成功执行了"+str(a1)+"秒") window = tk.Tk() window.title("连点程序的测试") # 创建大标题标签 title_label = tk.Label(window, text="连点器",font=("Arial", 16, "bold")) base_path=os.path.dirname(os.path.abspath(__file__));imagename="cat.gif" imagepath=os.path.join(base_path,imagename) # 创建按钮 button1 = tk.Button(window, text="点击鼠标右键", command=mr) button2 = tk.Button(window, text="点击鼠标左键", command=ml) default_value = tk.IntVar(value=1) label1 = tk.Label(window, text="输入时间(默认1秒)") entry1 = tk.Entry(window,textvariable=default_value) # 创建标签用于显示结果 result_label = tk.Label(window, text="执行结果:") # 将组件放置在窗口上 title_label.pack(pady=10) if os.path.exists(imagepath): image=Image.open(imagepath) imagewidth=300;imageheight=300;image=image.resize((imagewidth,imageheight)) photo=ImageTk.PhotoImage(image) labelimage=tk.Label(window,image=photo) labelimage.pack() else: labelimage=tk.Label(window,text="图片丢失") labelimage.pack() label1.pack() entry1.pack() button1.pack() button2.pack() result_label.pack() # 进入消息循环 window.mainloop()

这段代码执行后,会跳出一个可视化的框,如下图:

 

 默认时间输入的是1秒,注意不要让【输入时间(默认1秒)】下面的这部分为空,否则会报错无法执行!

这个程序是延迟1秒执行的,方便你快速把鼠标移动到需要连点的位置

例如:你输入了2秒后点击了【点击鼠标右键】,那么它将在你点击按钮后,延迟1秒再执行,持续执行2秒

例如:你输入了5秒后点击了【点击鼠标右键】,那么它将在你点击按钮后,延迟1秒再执行,持续执行5秒

也就是说,你输入的秒数是持续点击多久,而不是延迟执行的时间,延迟1秒是为了方便你把鼠标放到需要连点的地方。

源码的解压密码是:blackstar

使用愉快!

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有