[Python] 纯文本查看 复制代码
import tkinter as tk
import pyautogui
import datetime
import keyboard
from tkinter import ttk
# 添加一个全局变量作为停止标志
running = True
root_window = tk.Tk()
root_window.resizable(0, 0)
root_window.title("定时点击器——吾爱破解论坛-canso123")
kuan = root_window.winfo_screenwidth()
gao = root_window.winfo_screenheight()
root_window.geometry(f"900x800+{kuan // 3}+{gao // 12}")
root_window["background"] = 'light green'
var0 = tk.StringVar()
var1 = tk.StringVar()
var2 = tk.StringVar()
var3 = tk.StringVar()
var4 = tk.StringVar()
var5 = tk.StringVar()
var6 = tk.StringVar()
var7 = tk.StringVar()
# 用于存储 checkbutton 的状态
show_coordinates = tk.BooleanVar()
# 用于存储每个坐标的延迟时间
delay_vars = [tk.StringVar() for _ in range(4)]
def on_stop_key_pressed(e):
global running
if e.name == 'esc':
running = False
keyboard.on_press(on_stop_key_pressed)
def ShuaXin():
a = str(datetime.datetime.now().strftime('%H:%M:%S:%f'))[0:10]
var0.set(a)
if show_coordinates.get():
xy = pyautogui.position()
var7.set(str(xy))
else:
var7.set("")
root_window.after(100, ShuaXin)
ShuaXin()
def DianJi():
global running
running = True
a1 = str(datetime.datetime.now().strftime('%H:%M:%S:%f'))[0:10]
print(a1)
b = str(entry1.get())
if not running:
return
if a1 == b:
print("时间到了,抢购")
num = 0
while a1 == b and running:
delays = [int(delay_vars[i].get()) if delay_vars[i].get() else 0 for i in range(4)]
if entry4.get() == '' and entry5.get() == '' and entry6.get() == '' and entry3.get()!= '':
x3, y3 = map(int, entry3.get().split(','))
pyautogui.click(x3, y3)
pyautogui.sleep(delays[0] / 1000)
if entry5.get() == '' and entry6.get() == '' and entry3.get()!= '' and entry4.get()!= '':
x3, y3 = map(int, entry3.get().split(','))
x4, y4 = map(int, entry4.get().split(','))
pyautogui.click(x3, y3)
pyautogui.sleep(delays[0] / 1000)
pyautogui.click(x4, y4)
pyautogui.sleep(delays[1] / 1000)
if entry6.get() == '' and entry3.get()!= '' and entry4.get()!= '' and entry5.get()!= '':
x3, y3 = map(int, entry3.get().split(','))
x4, y4 = map(int, entry4.get().split(','))
x5, y5 = map(int, entry5.get().split(','))
pyautogui.click(x3, y3)
pyautogui.sleep(delays[0] / 1000)
pyautogui.click(x4, y4)
pyautogui.sleep(delays[1] / 1000)
pyautogui.click(x5, y5)
pyautogui.sleep(delays[2] / 1000)
if entry3.get()!= '' and entry4.get()!= '' and entry5.get()!= '' and entry6.get()!= '':
x3, y3 = map(int, entry3.get().split(','))
x4, y4 = map(int, entry4.get().split(','))
x5, y5 = map(int, entry5.get().split(','))
x6, y6 = map(int, entry6.get().split(','))
pyautogui.click(x3, y3)
pyautogui.sleep(delays[0] / 1000)
pyautogui.click(x4, y4)
pyautogui.sleep(delays[1] / 1000)
pyautogui.click(x5, y5)
pyautogui.sleep(delays[2] / 1000)
pyautogui.click(x6, y6)
pyautogui.sleep(delays[3] / 1000)
num += 1
if num == int(entry2.get()) or not running:
# os.system("shutdown -h")
break
root_window.after(100, DianJi)
LB0 = tk.Label(root_window, text="系统时间:", font=("宋体", 16), relief='groove', background='yellow')
LB0.grid(row=0, column=0, padx=10, pady=10)
entry0 = tk.Entry(root_window, textvariable=var0, font=("宋体", 22))
entry0.grid(row=0, column=2, padx=10, pady=10)
LB1 = tk.Label(root_window, text="点击时间:", font=("宋体", 16), relief='groove', background='aqua')
LB1.grid(row=1, column=0, padx=10, pady=10)
entry1 = tk.Entry(root_window, textvariable=var1, font=("宋体", 22))
entry1.grid(row=1, column=2, padx=10, pady=10)
LB2 = tk.Label(root_window, text="点击次数:", font=("宋体", 16), relief='groove', background='orchid')
LB2.grid(row=2, column=0, sticky="w", padx=10, pady=15)
entry2 = tk.Entry(root_window, textvariable=var2, font=("宋体", 22))
entry2.grid(row=2, column=2)
LB3 = tk.Label(root_window, text="坐标1:", font=("宋体", 16), relief='groove', background='wheat')
LB3.grid(row=3, column=0, sticky="w", padx=10, pady=15)
entry3 = tk.Entry(root_window, textvariable=var3, font=("宋体", 22))
entry3.grid(row=3, column=2)
delay_label3 = tk.Label(root_window, text="延迟1(毫秒):", font=("宋体", 16), relief='groove', background='wheat')
delay_label3.grid(row=3, column=3, sticky="w", padx=10, pady=15)
delay_entry3 = tk.Entry(root_window, textvariable=delay_vars[0], font=("宋体", 22))
delay_entry3.grid(row=3, column=4)
LB4 = tk.Label(root_window, text="坐标2:", font=("宋体", 16), relief='groove', background='wheat')
LB4.grid(row=4, column=0, sticky="w", padx=10, pady=15)
entry4 = tk.Entry(root_window, textvariable=var4, font=("宋体", 22))
entry4.grid(row=4, column=2)
delay_label4 = tk.Label(root_window, text="延迟2(毫秒):", font=("宋体", 16), relief='groove', background='wheat')
delay_label4.grid(row=4, column=3, sticky="w", padx=10, pady=15)
delay_entry4 = tk.Entry(root_window, textvariable=delay_vars[1], font=("宋体", 22))
delay_entry4.grid(row=4, column=4)
LB5 = tk.Label(root_window, text="坐标3:", font=("宋体", 16), relief='groove', background='wheat')
LB5.grid(row=5, column=0, sticky="w", padx=10, pady=15)
entry5 = tk.Entry(root_window, textvariable=var5, font=("宋体", 22))
entry5.grid(row=5, column=2)
delay_label5 = tk.Label(root_window, text="延迟3(毫秒):", font=("宋体", 16), relief='groove', background='wheat')
delay_label5.grid(row=5, column=3, sticky="w", padx=10, pady=15)
delay_entry5 = tk.Entry(root_window, textvariable=delay_vars[2], font=("宋体", 22))
delay_entry5.grid(row=5, column=4)
LB6 = tk.Label(root_window, text="坐标4:", font=("宋体", 16), relief='groove', background='wheat')
LB6.grid(row=6, column=0, sticky="w", padx=10, pady=15)
entry6 = tk.Entry(root_window, textvariable=var6, font=("宋体", 22))
entry6.grid(row=6, column=2)
delay_label6 = tk.Label(root_window, text="延迟4(毫秒):", font=("宋体", 16), relief='groove', background='wheat')
delay_label6.grid(row=6, column=3, sticky="w", padx=10, pady=15)
delay_entry6 = tk.Entry(root_window, textvariable=delay_vars[3], font=("宋体", 22))
delay_entry6.grid(row=6, column=4)
BT = tk.Button(root_window, text="点击开始", font=("宋体", 16), width=14, height=2, relief='groove', command=DianJi,
background='green')
BT.place(x=640, y=650, width=200, height=80)
entry7 = tk.Entry(root_window, textvariable=var7, font=("宋体", 20))
entry7.place(x=10, y=650, width=600, height=80)
style = ttk.Style()
# 配置 Checkbutton 的样式
style.configure('TCheckbutton', background='wheat', font=("宋体", 16), relief='groove')
# 设置变量
show_coordinates = tk.BooleanVar()
# 在 GUI 布局部分添加一个 Checkbutton
CB_show_coordinates = ttk.Checkbutton(root_window, text="实时坐标", variable=show_coordinates, style='TCheckbutton')
CB_show_coordinates.grid(row=7, column=0, sticky="w", padx=10, pady=15)
root_window.mainloop()