最近玩雷霆战机,但是金币又很少,百度搜了看可以用自动连点器刷无尽,但是我手机不可能24小时挂着,模拟器又需要把微信退出去,就找pc版的连点器吧,找了好几个都要RMB,GitHub上也少,就自己用py写一个吧,简简单单,可以定时,多点位就能满足,下面贴上代码和运行效果:
import
time,re,os,pickle
import
tkinter as tk
from
tkinter
import
messagebox,ttk
import
pyautogui
import
keyboard
import
logging
import
threading
coordinates
=
[]
is_running
=
False
click_count
=
0
clickNum
=
0
logging.basicConfig(level
=
logging.INFO,
format
=
'%(asctime)s - %(levelname)s - %(message)s'
)
def
get_mouse_position():
global
clickNum
x, y
=
pyautogui.position()
coordinates.append((x, y))
update_message(f
"{x}, {y}\n"
)
def
clear():
global
click_count
entry1.delete(
0
, tk.END)
entry2.delete(
0
, tk.END)
coordinates.clear()
is_running
=
False
click_count
=
0
message.config(state
=
'normal'
)
message.delete(
'1.0'
, tk.END)
message.config(state
=
'disabled'
)
messagebox.showinfo(
"信息"
,
"所有数据已清空"
)
def
startClickThread():
global
is_running,click_count
seconds1
=
float
(entry1.get())
seconds2
=
float
(entry2.get())
while
is_running:
try
:
for
x, y
in
coordinates:
pyautogui.moveTo(x, y)
pyautogui.click()
time.sleep(seconds2)
click_count
+
=
1
current_time
=
time.strftime(
"%Y-%m-%d %H:%M:%S"
, time.localtime())
update_message(f
"{current_time} 第 {click_count} 次循环结束\n"
)
time.sleep(seconds1)
except
pyautogui.FailSafeException:
update_message(
"操作取消,因为鼠标移动到了屏幕角落。\n"
)
is_running
=
False
except
Exception as e:
logging.error(f
"发生错误:{e}"
)
is_running
=
False
def
startOrStop():
global
is_running
if
check_empty():
messagebox.showwarning(
"警告"
,
"时间和坐标列表都不能为空!\n"
)
return
if
not
is_running:
is_running
=
True
update_message(
"-----启动连点,当前每 {} 秒点击一次-----\n"
.
format
(entry2.get()))
threading.Thread(target
=
startClickThread).start()
else
:
is_running
=
False
update_message(
"-----停止连点-----\n"
)
def
check_empty():
if
entry1.get().strip()
=
=
"
" or entry2.get().strip() == "
":
return
True
if
len
(coordinates)
=
=
0
:
return
True
return
False
def
update_message(message_text):
def
safe_update():
message.config(state
=
'normal'
)
message.insert(tk.END, message_text)
message.config(state
=
'disabled'
)
message.yview(tk.END)
root.after(
0
, safe_update)
keyboard.add_hotkey(
'f6'
, get_mouse_position)
keyboard.add_hotkey(
'f7'
, startOrStop)
root
=
tk.Tk()
screen_width
=
root.winfo_screenwidth()
screen_height
=
root.winfo_screenheight()
win_width
=
650
win_height
=
400
x
=
(screen_width
/
2
)
-
(win_width
/
2
)
y
=
(screen_height
/
2
)
-
(win_height
/
2
)
root.geometry(f
'{win_width}x{win_height}+{int(x)}+{int(y)}'
)
script_dir
=
os.path.dirname(os.path.abspath(__file__))
icon_path
=
os.path.join(script_dir,
'config'
,
'click.png'
)
win_image
=
tk.PhotoImage(
file
=
'.\\config\\click.png'
)
root.iconphoto(
False
, win_image)
root.title(
"自动连点器"
)
root.geometry(
"650x400"
)
label
=
tk.Label(root, text
=
"按下F6获取当前鼠标坐标"
)
label.pack(pady
=
10
)
frame1
=
tk.Frame(root)
frame1.pack(fill
=
tk.X, expand
=
True
)
label1
=
tk.Label(frame1, text
=
"距离下一个循环点击时间:"
)
label1.pack(side
=
tk.LEFT, fill
=
tk.X, padx
=
(
20
,
10
))
entry1
=
tk.Entry(frame1, width
=
10
)
entry1.pack(side
=
tk.LEFT, fill
=
tk.X, expand
=
True
)
label2
=
tk.Label(frame1, text
=
"s/秒"
)
label2.pack(side
=
tk.LEFT, fill
=
tk.X, padx
=
(
20
,
10
))
frame2
=
tk.Frame(root)
frame2.pack(fill
=
tk.X, expand
=
True
)
label3
=
tk.Label(frame2, text
=
"距离下一个点击时间:"
)
label3.pack(side
=
tk.LEFT, fill
=
tk.X, padx
=
(
20
,
10
))
entry2
=
tk.Entry(frame2, width
=
10
)
entry2.pack(side
=
tk.LEFT, fill
=
tk.X, expand
=
True
)
label4
=
tk.Label(frame2, text
=
"s/秒"
)
label4.pack(side
=
tk.LEFT, fill
=
tk.X, padx
=
(
20
,
10
))
frame5
=
tk.Frame(root)
frame5.pack(fill
=
tk.X, expand
=
True
)
button1
=
tk.Button(frame5, text
=
"清空"
, command
=
clear)
button1.pack(side
=
tk.LEFT, fill
=
tk.X, expand
=
True
)
button2
=
tk.Button(frame5, text
=
"启动/停止(F7)"
, command
=
startOrStop)
button2.pack(side
=
tk.LEFT, fill
=
tk.X, expand
=
True
)
message
=
tk.Text(root, state
=
'disabled'
)
message.pack(fill
=
tk.BOTH, expand
=
True
,padx
=
5
, pady
=
5
)
root.mainloop()
keyboard.wait()