微信双开助手
转自电脑上多开微信
创建以下脚本
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import pickle
import subprocess
import tkinter as tk
import tkinter.messagebox
import tkinter.filedialogwindow = tk.Tk()window.title('多开微信配置')window.geometry('400x300')var_name = tk.StringVar()
var_name.set(r"D:\Program Files (x86)\Tencent\WeChat")
tk.Label(window, text='微信安装路径:', font=('Arial', 10)).place(x=10, y=135)
entry_usr_name = tk.Entry(window, textvariable=var_name, font=('Arial', 13))
entry_usr_name.place(x=120, y=135)BASE_DIR = os.path.abspath(os.path.dirname(__file__))
if "dist" in BASE_DIR:BASE_DIR = BASE_DIR.rstrip("dist")r_path = var_name.get()
cf_path = os.path.join(r_path, "config_info.pickle")close_flag = tk.StringVar()config_info = {}
try:with open(cf_path, 'rb') as usr_file:config_info = pickle.load(usr_file)if config_info.get("w_path") == "ok":r_path = config_info["r_path"]close_flag.set("ok")
except FileNotFoundError:try:if os.path.exists(r_path):with open(cf_path, 'wb') as usr_file:config_info = {'w_path': 'error'}close_flag.set("error")pickle.dump(config_info, usr_file)except Exception as e:tkinter.messagebox.showinfo("提示:", str(e) + "--" + BASE_DIR)def get_path():f_path = tkinter.filedialog.askdirectory()if f_path:var_name.set(f_path)def exc_file(r_path):try:cmd1 = "PATH %s" % r_pathcmd2 = "start WeChat.exe&WeChat.exe"cmd = cmd1 + "&" + cmd2f = subprocess.Popen(args=cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,stdin=subprocess.DEVNULL)window.destroy()except Exception as e:tkinter.messagebox.showinfo("提示:", "启动失败 %s" % e)def config_path():r_path = var_name.get()w_path = os.path.join(r_path, "WeChat.exe")if os.path.exists(w_path):cf_path = os.path.join(r_path, "config_info.pickle")with open(cf_path, 'wb') as usr_file:config_info['w_path'] = "ok"config_info["r_path"] = r_pathpickle.dump(config_info, usr_file)exc_file(r_path=r_path)else:tkinter.messagebox.showinfo("提示:", "请正确设置微信的安装路径")btn_login = tk.Button(window, text='选择', command=get_path)
btn_login.place(x=320, y=132)
btn_sign_up = tk.Button(window, text='确定', command=config_path)
btn_sign_up.place(x=170, y=180)if close_flag.get() == "ok":exc_file(r_path=r_path)window.mainloop()
在python路径下放一个ico文件,打包。
查看当前的环境,我们进入base环境,activate 虚拟环境名
,如果是linux是source activate 虚拟环境名
。
先安装pyinstaller
conda install pyinstaller
在cmd下打包
pyinstaller -F ./sss.py --noconsole -i favicon.ico
启动,如果是安装在c盘,路径一般就是C:\Program Files (x86)\Tencent\WeChat
,如果是D盘,就是D:\Program Files (x86)\Tencent\WeChat
。