程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Realize multiple opening of wechat, nailing and other software with Python

編輯:Python

I found that a lot of what forum friends share is through cmd Go to start Multiple wechat
Although it can realize more opening , But not flexible enough , For example, I logged in to a wechat this morning , It's not easy to login in the afternoon
It could be me, of course start The posture is not right . So I searched the single instance principle , I have realized a ready to use and open . At present, many software restrict single instance , Most software uses Mutex To achieve
And this thing we can use handle Go and kill it , And does not affect the use of .
Nailing is the same procedure however Mutex Their names are different
The nail I tested was :

”\Sessions\1\BaseNamedObjects\{ {239B7D43-86D5-4E5C-ADE6-CEC42155B475}}DingTalk“

Dry goods mainly include :

① 200 Multiple copies Python e-book ( And classic books ) Should have

② Python Standard library information ( The most complete Chinese version )

③ Project source code ( Forty or fifty interesting and reliable hand training projects and source code )

④ Python Basic introduction 、 Reptiles 、 Network development 、 Big data analysis video ( Suitable for Xiaobai to learn )

⑤ Python Learning Roadmap ( Farewell to bad learning )

Python Study Q Group 101677771


Here we need to use two Microsoft software Namely :procexp handle
Next, start the text :
First of all, let's judge manually Mutex Which is .
That's what we need procexp.exe 了 Run the program as an administrator .
Select wechat process Press Ctrl+L The bottom half of the picture will appear .

In the software, we can find type yes Mutant Of Then right click to close Try one by one I've tried here, so I won't demonstrate Directly to everyone

name
\Sessions\1\BaseNamedObjects\WeChat_GlobalConfig_Multi_Process_Mutex


After this step The mission of this tool is completed ! Next use handle 了
stay cmd Enter the following code

handle -a -u -p 12668 "\Sessions\1\BaseNamedObjects\WeChat_GlobalConfig_Multi_Process_Mutex"

Then we can close the handle

handle -p 12668 -c 460 -y

Be careful : This code requires administrator privileges
Then we can open wechat .
Now let's use python To realize
Code may be different from analysis because

"\Sessions\1\BaseNamedObjects\WeChat_GlobalConfig_Multi_Process_Mutex"

Medium 1 Sometimes it turns into other numbers , So I used the matching rule
Combine the code with handle.exe Put it in a directory

import os
import re
import psutil
def get_pid(name):
"""
Get all wechat processes
"""
process_list = psutil.pids()
pids = []
for pid in process_list:
if psutil.Process(pid).name() == name:
pids.append(pid)
return pids
def more_open(path):
pids = get_pid("WeChat.exe")
for pid in pids:
# Traverse all wechat pid hold Mutex Get rid of it
cmd = f"handle -a -u -p {pid}"
with os.popen(cmd) as f:
result = f.read()
search_result = ""
for i in result.split("\n"):
if i.strip():
if i.strip().endswith("_WeChat_App_Instance_Identity_Mutex_Name"):
search_result += i
if not search_result:
os.startfile(path)
continue
re_result = re.findall('(\d+): Mutant', search_result, re.S)
# The loop above is a match Mutex Of handle
if re_result:
for _id in re_result:
os.system(f'handle -p {pid} -c {_id} -y')
os.startfile(path)
path = "D:\Program Files (x86)\Tencent\WeChat\WeChat.exe"
more_open(path)

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved