使用说明:
1启动后选择下拉框中连点器
2输入点击次数,点击间隔,开始工作时间间隔(假设x秒)
3点击“确定”,连点就会在x秒后开始
4若想中途停止,请按Enter键
5结束后弹出窗口提示
以下代码还需要一张图片,格式PNG,命名为‘欣欣公益.PNG’才能正常运行。
编译器IDLE3.11运行没问题,不知其他版本如何。
from tkinter import *
from tkinter import messagebox,filedialog,ttk
import ctypes
from shutil import *
import pyautogui as pag
from time import *
from pynput import keyboard
import threading
global isEnd
isEnd=0
def liandi():
# 改进版
pag.PAUSE = 0
def mouse():
def keyboard_on_press(key):
if key == keyboard.Key.enter:
global isEnd
isEnd=1
return False
def start_key_listen():
with keyboard.Listener(on_press=keyboard_on_press) as KeyboardListener:
KeyboardListener.join()
t1 = threading.Thread(target=start_key_listen)
t1.start()
try:
print(c)
except NameError:
messagebox.showerror('警告','请选择按键')
return 0
try:
b=int(e1.get())
e=float(e2.get())
f=int(e3.get())
except:
messagebox.showerror('警告','请输入数字')
return 0
messagebox.showinfo('注意','请注意:您需要{}'.format(f)+'秒内移到需要点击的位置,然后不要动,等待快速连点。')
sleep(f)
x,y = pag.position()
d = 'left'
if c:
d = 'right'
for i in range(0,b):
global isEnd
if isEnd:
messagebox.showinfo('提示','连点停止')
break
return False
pag.click(x,y,button = d)
sleep(e)
messagebox.showinfo('提示','连点结束')
isEnd=0
def cishu(a):#左右键区分
global c
c=a
def retur():
root.destroy()
root=Tk()
root.title('连点器')
root.geometry("500x200+1100+150")
root.resizable(False,False)
b1=Button(root,text="开始",command=lambda:mouse()).place(x=180,y=130)
b2=Button(root,text="返回",command=lambda:retur()).place(x=300,y=130)
l1=Label(root,text="请输入点击次数:").place(x=5,y=50)
l2=Label(root,text="点击延迟:").place(x=250,y=50)
l2=Label(root,text="开始工作时间(单位:秒)").place(x=5,y=100)
e1=Entry(root)
e1.place(x=100,y=50)
e2=Entry(root)
e2.place(x=320,y=50)
e3=Entry(root)
e3.place(x=150,y=100)
v=IntVar()
v=1
Radiobutton(root,text = '右键',variable=v,value = 2,command=lambda:cishu(1)).place(x=50,y=0)
Radiobutton(root,text = '左键',variable=v,value = 1,command=lambda:cishu(0)).place(x=0,y=0)
A=0
whnd = ctypes.windll.kernel32.GetConsoleWindow()
if whnd != 0:
ctypes.windll.user32.ShowWindow(whnd, 0)
ctypes.windll.kernel32.CloseHandle(whnd)
def interface():
""""界面编写位置"""
def pick(*args):# 处理事件,*args表示可变参数
if c1.get()=='连点器':
liandi()
value = StringVar()
values = ['连点器']
value.set(' ')
c1= ttk.Combobox(
master=r, # 父容器
height=10, # 高度,下拉显示的条目数量
width=20, # 宽度
state='readonly', # 设置状态 normal(可选可输入)、readonly(只可选)、 disabled(禁止输入选择)
cursor='arrow', # 鼠标移动时样式 arrow, circle, cross, plus...
font=('', 15), # 字体
textvariable=value, # 通过StringVar设置可改变的值
values=values ,# 设置下拉框的选项
)
# 绑定事件,下拉列表框被选中时,绑定pick()函数
c1.bind("<>",pick)
c1.pack(padx=2.5,pady=2)
r=Tk()
r.title("欣欣公益")
r.geometry("500x200+1100+150")
r.iconphoto(True, PhotoImage(file='欣欣公益.PNG'))
Label(r, text="欣欣公益", font="Calibri 30 bold", fg="red").pack(padx=0, pady=38)
interface()