连点器--基于Python实现

全民制作人们大家好,大学牲和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

使用愉快!

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值