微信多开小工具,可以自定义开启几个窗口,附源码

[复制链接]
153 |11
发表于 2025-9-22 00:37:58 | 显示全部楼层 |阅读模式
软件功能:很简单,选数量,想开几个选几个

下载链接:https://caiyun.139.com/w/i/2oRh9PS0MG9mw
提取码:du5m



[Python]  
  1. import os
  2. import subprocess
  3. import sys
  4. import tkinter as tk
  5. from tkinter import messagebox, filedialog, ttk
  6. from pathlib import Path
  7. import time
  8. import psutil
  9. def resource_path(relative_path):
  10.     try:
  11.         base_path = sys._MEIPASS
  12.     except Exception:
  13.         base_path = os.path.abspath(".")
  14.     return os.path.join(base_path, relative_path)
  15. def open_wechat(wechat_path: str, count: int):
  16.     """启动指定数量的微信实例"""
  17.     if not os.path.exists(wechat_path):
  18.         raise FileNotFoundError(f"未找到微信程序,路径不存在:{wechat_path}")
  19.     for _ in range(count):
  20.         subprocess.Popen([wechat_path])
  21. def browse_path():
  22.     """浏览并选择微信路径"""
  23.     path = filedialog.askopenfilename(
  24.         title="选择微信程序",
  25.         filetypes=[("微信程序", "WeChat.exe"), ("所有文件", "*.*")]
  26.     )
  27.     if path:
  28.         path_entry.delete(0, tk.END)
  29.         path_entry.insert(0, path)
  30. def check_wechat_running():
  31.     """检查微信是否已成功启动"""
  32.     for proc in psutil.process_iter(['name']):
  33.         if 'WeChat.exe' in proc.info['name']:
  34.             return True
  35.     return False
  36. def start_wechat():
  37.     """开始启动微信"""
  38.     try:
  39.         wechat_path = path_entry.get().strip()
  40.         count = int(count_combobox.get())
  41.         if not wechat_path:
  42.             status_label.config(text="请输入微信路径", fg="red")
  43.             return
  44.         if count < 1:
  45.             status_label.config(text="数量必须大于0", fg="red")
  46.             return
  47.         open_wechat(wechat_path, count)
  48.         status_label.config(text=f"正在启动微信...", fg="blue")
  49.         # 延迟检查微信是否启动成功
  50.         root.after(1000, lambda: check_and_close())
  51.     except FileNotFoundError:
  52.         status_label.config(text="微信程序路径不存在", fg="red")
  53.     except Exception as e:
  54.         status_label.config(text=f"启动失败: {str(e)}", fg="red")
  55. def check_and_close():
  56.     """检查微信是否启动成功,成功则关闭工具"""
  57.     if check_wechat_running():
  58.         root.destroy()  # 关闭工具窗口
  59.     else:
  60.         # 最多尝试5次
  61.         if not hasattr(check_and_close, 'attempts'):
  62.             check_and_close.attempts = 0
  63.         check_and_close.attempts += 1
  64.         if check_and_close.attempts < 5:
  65.             # 继续检查
  66.             root.after(1000, check_and_close)
  67.         else:
  68.             # 超时显示错误
  69.             status_label.config(text="启动超时,请手动检查", fg="red")
  70.             check_and_close.attempts = 0  # 重置计数器
  71. # 创建主窗口
  72. root = tk.Tk()
  73. root.title("微信多开工具")
  74. root.geometry("500x200")
  75. root.resizable(False, False)
  76. # 设置窗口居中
  77. window_width = 500
  78. window_height = 200
  79. screen_width = root.winfo_screenwidth()
  80. screen_height = root.winfo_screenheight()
  81. x = (screen_width - window_width) // 2
  82. y = (screen_height - window_height) // 2
  83. root.geometry(f"{window_width}x{window_height}+{x}+{y}")
  84. # 设置窗口图标
  85. try:
  86.     icon_path = resource_path("text.ico")  # 使用资源路径函数获取图标
  87.     if os.path.exists(icon_path):
  88.         root.iconbitmap(icon_path)
  89. except Exception as e:
  90.     print(f"加载图标失败: {e}")
  91. # 创建标题标签
  92. title_label = tk.Label(root, text="微信多开工具", font=("Microsoft YaHei", 16, "bold"))
  93. title_label.pack(pady=10)
  94. # 创建路径输入框和浏览按钮
  95. path_frame = tk.Frame(root)
  96. path_frame.pack(fill=tk.X, padx=20, pady=5)
  97. path_label = tk.Label(path_frame, text="微信路径:", width=10)
  98. path_label.pack(side=tk.LEFT)
  99. path_entry = tk.Entry(path_frame)
  100. path_entry.pack(side=tk.LEFT, fill=tk.X, expand=True, padx=5)
  101. browse_button = tk.Button(path_frame, text="浏览...", command=browse_path)
  102. browse_button.pack(side=tk.LEFT)
  103. # 创建数量选择下拉框和状态显示
  104. count_frame = tk.Frame(root)
  105. count_frame.pack(fill=tk.X, padx=20, pady=5)
  106. count_label = tk.Label(count_frame, text="实例数量:", width=10)
  107. count_label.pack(side=tk.LEFT)
  108. # 创建下拉选择框,选项为1-9
  109. count_combobox = ttk.Combobox(count_frame, values=list(range(2, 11)), width=5)
  110. count_combobox.current(0)  # 默认选择1
  111. count_combobox.pack(side=tk.LEFT, padx=5)
  112. # 添加状态显示标签
  113. status_label = tk.Label(count_frame, text="", fg="green")
  114. status_label.pack(side=tk.LEFT, padx=10)
  115. # 创建启动按钮
  116. start_button = tk.Button(root, text="启动微信", command=start_wechat, bg="#4CAF50", fg="white", height=2)
  117. start_button.pack(pady=20, fill=tk.X, padx=100)
  118. # 尝试设置默认路径
  119. default_wechat_path = Path(r"C:\Program Files\Tencent\WeChat\WeChat.exe")
  120. if default_wechat_path.exists():
  121.     path_entry.insert(0, str(default_wechat_path))
  122. # 运行主循环
  123. root.mainloop()
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

发表于 2025-9-22 00:38:58 | 显示全部楼层
这么麻烦吗?还用写程序?
@echo off

start /d "C:\Program Files (x86)\Tencent\WeChat\Weixin\" Weixin.exe

start /d "C:\Program Files (x86)\Tencent\WeChat\Weixin\" Weixin.exe

exit

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

发表于 2025-9-22 00:39:12 | 显示全部楼层
恶心的网盘,登录下载
回复

使用道具 举报

发表于 2025-9-22 00:39:52 | 显示全部楼层
很实用,点赞!
回复

使用道具 举报

发表于 2025-9-22 00:40:07 | 显示全部楼层
哇,感谢分享
回复

使用道具 举报

发表于 2025-9-22 00:40:52 | 显示全部楼层
感谢分享
回复

使用道具 举报

发表于 2025-9-22 00:41:24 | 显示全部楼层
...............
回复

使用道具 举报

发表于 2025-9-22 00:41:54 | 显示全部楼层
强啊大佬
回复

使用道具 举报

发表于 2025-9-22 00:42:48 | 显示全部楼层
什么版本都可以吗?
回复

使用道具 举报

发表于 2025-9-22 00:43:44 | 显示全部楼层
这是我见过最好用的!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表