wechat 多开

用python写的多开

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#coding: UTF-8
import os
import subprocess
import tkinter
from tkinter import messagebox
from tkinter import filedialog


#关闭提示
def close_app():
if messagebox.askokcancel("提示","确定要退出吗?"):
window.destroy() #销毁

#获取wechat路径
def OpenFilePath():
file_path = filedialog.askdirectory() #获取路径
if file_path:
FilePath.set(file_path) #如果路径为空,设置为默认路径
#检查路径
def CheckPath():
path = FilePath.get()
#os.path.join方法实现两个参数连接
wechat_path = os.path.join(path, "WeChat.exe")
if os.path.exists(wechat_path):
startWechat(path)
else:
messagebox.showinfo("提示:", "请正确设置微信的安装路径")

#启动微信
def startWechat(path):
try:
#cmd命令
# cmd1 = "PATH %s" %path
cmd = "start WeChat.exe"
# cmd = cmd1 + "&" + cmd2
#获取需要打开的数量,强制转化为int类型
Count_Amount = int(Amount.get())
if Count_Amount < 1:
messagebox.showinfo("提示:","不能小于1,请输入1~6之间的数字")
return
#经过测试,每次打开超过6个时,可能会出现数量异常
if Count_Amount > 6:
messagebox.showinfo("提示:","不能大于6,请输入1~6之间的数字")
return
for i in range(0,Count_Amount,1):
#传入需要执行的args命令,cwd路径
subprocess.Popen(args=cmd, shell=True, cwd=path)
# window.destroy()
except Exception as e:
messagebox.showerror("提示:", "请输入整数,%s" % e)

window = tkinter.Tk()
#photo = tkinter.PhotoImage(file="background.jpg")
window.title('微信多开')
#设置窗口大小及启动时的位置
window.geometry('400x200+400+200')
#设置窗口不可改变大小
window.resizable(0, 0)
#存储持久化数据
FilePath = tkinter.StringVar()
Amount = tkinter.StringVar()
#设置默认路径,默认数值
FilePath.set(r"C:\Program Files (x86)\Tencent\WeChat")
Amount.set(2)
#label为标注,entry为输入框
tkinter.Label(window, text='微信安装位置:', font=('华文行楷', 11)).place(x=10, y=50)
tkinter.Label(window, text='(注意:为wechat.exe的路径)', fg="#FF0000", font=('华文行楷', 10)).place(x=110, y=70)
tkinter.Entry(window, width=32, textvariable=FilePath, font=('Arial', 9)).place(x=110, y=50)
tkinter.Label(window, text='多开微信数量:', font=('华文行楷', 11)).place(x=10, y=103)
#tkinter.Label(window, text='(注意:多开数量不支持超过6个)', fg="#FF0000" ,font=('华文行楷', 10)).place(x=110, y=125)
tkinter.Entry(window, width=5, textvariable=Amount, font=('Arial', 10)).place(x=110, y=103)
#初始化按钮
Choice_Button = tkinter.Button(window, text='选择', command=OpenFilePath)
Choice_Button.place(x=350, y=45)
Confirm_Button = tkinter.Button(window, bd=6, width=6, text='确定', command=CheckPath)
Confirm_Button.place(x=180, y=150)
#关闭app事件
window.protocol("WM_DELETE_WINDOW",close_app)
window.mainloop()