PC版微信多开工具解决方案

朋友办公用的电脑需要多开微信,但百度搜索一番,这类工具大多开始收费或者自带各种捆绑,求助于我,闲暇之余做了一个简单的工具,给他使用,在这里分享一下。

本文默认读者有Python基础知识,能自行阅读理解代码含义。并提供打包后的EXE文件下载。
原创首发CSDN文章,转载请注明来源。

  • 实现原理:
    win平台下多次执行  start "" 微信地址"命令来一次性开启多个微信客户端 
  •  代码运行环境:
    python3.8以下(为了适配win7(x64)平台)
    pyside6 6.1版本或以下
    操作平台:win7(x64位)或以上均可
  • 软件界面
    PC版微信多开工具解决方案_第1张图片
  • 实现代码:
    主程序代码
#pyside6创建的ui编译成的模块文件,主程序代码下方代码为模块文件代码
from Ui_vx import Ui_vx
from PySide6.QtWidgets import QApplication,QWidget
import os 
import json

class MyWindow(QWidget,Ui_vx):
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        #当前工作目录设为当前程序所在目录
        os.chdir(os.path.dirname(__file__))
        self.bind()#绑定页面部件信号
        self.load_default_config()#加载默认配置
    
    def load_default_config(self):
        '''
        加载默认配置
        '''
        try:
            with open('config.json','r') as file:
                config_dict = json.load(file)
            self.address_lineEdit.setText(config_dict['address'])
            self.number_spinBox.setValue(config_dict['number'])
            self.address = config_dict['address']
            self.number = config_dict['number']
        except:
            config_dict={}
            config_dict.update({'address':'','number':2})
            with open('config.json','w') as f:
                json.dump(config_dict,f,ensure_ascii=False,indent=4)
        
    def bind(self):
        '''
        绑定页面配置文件
        '''
        self.address_lineEdit.textChanged.connect(self.change_config)
        self.number_spinBox.valueChanged.connect(self.change_config)
        self.start_btn.clicked.connect(self.start_vx)

    def change_config(self):
        '''
        配置改变时的槽函数
        '''
        self.config_dict = {}
        self.address = self.address_lineEdit.text()
        self.number = self.number_spinBox.value()
        self.config_dict.update({'address':self.address,'number':self.number})        
        with open('config.json' ,'w') as file:
            json.dump(self.config_dict,file,ensure_ascii=False,indent=4)

    def start_vx(self):
        '''
        启动微信客户端
        '''
        for _ in range(self.number):
            os.system(f'start "" "{self.address}"') 
        
if  __name__ == '__main__':
    app = QApplication([])
    window = MyWindow() 
    window.show()
    app.exec()

 UI模块文件代码

# -*- coding: utf-8 -*-

################################################################################
## Form generated from reading UI file 'vx.ui'
##
## Created by: Qt User Interface Compiler version 6.5.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################

from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
    QMetaObject, QObject, QPoint, QRect,
    QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
    QFont, QFontDatabase, QGradient, QIcon,
    QImage, QKeySequence, QLinearGradient, QPainter,
    QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QLabel, QLineEdit, QPushButton,
    QSizePolicy, QSpinBox, QWidget)

class Ui_vx(object):
    def setupUi(self, vx):
        if not vx.objectName():
            vx.setObjectName(u"vx")
        vx.resize(441, 156)
        self.address_lineEdit = QLineEdit(vx)
        self.address_lineEdit.setObjectName(u"address_lineEdit")
        self.address_lineEdit.setGeometry(QRect(100, 20, 301, 21))
        self.label = QLabel(vx)
        self.label.setObjectName(u"label")
        self.label.setGeometry(QRect(40, 20, 54, 16))
        self.label_2 = QLabel(vx)
        self.label_2.setObjectName(u"label_2")
        self.label_2.setGeometry(QRect(40, 70, 54, 16))
        self.start_btn = QPushButton(vx)
        self.start_btn.setObjectName(u"start_btn")
        self.start_btn.setGeometry(QRect(170, 70, 231, 24))
        self.label_3 = QLabel(vx)
        self.label_3.setObjectName(u"label_3")
        self.label_3.setGeometry(QRect(10, 110, 421, 20))
        self.number_spinBox = QSpinBox(vx)
        self.number_spinBox.setObjectName(u"number_spinBox")
        self.number_spinBox.setGeometry(QRect(100, 70, 42, 22))
        self.number_spinBox.setMinimum(2)
        self.number_spinBox.setMaximum(4)
        self.label_4 = QLabel(vx)
        self.label_4.setObjectName(u"label_4")
        self.label_4.setGeometry(QRect(20, 130, 361, 20))

        self.retranslateUi(vx)

        QMetaObject.connectSlotsByName(vx)
    # setupUi

    def retranslateUi(self, vx):
        vx.setWindowTitle(QCoreApplication.translate("vx", u"\u5fae\u4fe1\u5206\u8eab\u5de5\u5177(PC\u7248)", None))
        self.label.setText(QCoreApplication.translate("vx", u"\u5fae\u4fe1\u5730\u5740", None))
        self.label_2.setText(QCoreApplication.translate("vx", u"\u5f00\u542f\u6570\u91cf", None))
        self.start_btn.setText(QCoreApplication.translate("vx", u"\u7acb\u5373\u542f\u7528", None))
        self.label_3.setText(QCoreApplication.translate("vx", u"*\u9996\u6b21\u4f7f\u7528\u5f55\u5165\u5fae\u4fe1\u5730\u5740\u5230\u5730\u5740\u680f\u540e,\u70b9\u51fb\u7acb\u5373\u542f\u7528\u3002\u4f7f\u7528\u672c\u5de5\u5177\u524d\u4e0d\u8981\u767b\u5f55\u5fae\u4fe1", None))
        self.label_4.setText(QCoreApplication.translate("vx", u"\u8fc7\u591a\u7684\u5ba2\u6237\u7aef\u542f\u52a8\u53ef\u80fd\u4f1a\u9020\u6210\u5185\u5b58\u5d29\u6e83,\u672c\u7a0b\u5e8f\u6700\u9ad8\u9650\u5b9a4\u4e2a\u5ba2\u6237\u7aef", None))
    # retranslateUi

  • 代码解析:
    本程序是基于Pyside6的图形画操作界面,对用户友好。
    导入Pyside6 designer中绘制的Uil界面生成的模块文件
    导入pyside6其它必要的模块,OS,json模块 
    创建主窗口大类,初始化安装UI文件
    加载默认的配置文件,若配置文件不存在或报错,数据改动都会重写配置文件
    配置加载完成启动微信客户端,这里对客户端同时启动数量做了最大4个的限制,避免机器配置不高时引起内存崩溃
  • 其它事项
    本软件打包后生成的执行文件,可以运行在win7(x64)及以上操作系统,xp及32位操作系统由于历史年代久远且市面用户量已经很少,该解决方案不再支持,源码公开,如有需要可自行更改

你可能感兴趣的:(微信)