使用Python实现获取本机当前用户登陆过的微信ID!

使用Python实现获取本机当前用户登陆过的微信ID!

作者:JHC000000
这篇文章主要为大家详细介绍了如何使用Python实现获取本机当前用户登陆过的微信对应的wxid,文中的示例代码讲解详细,感兴趣的小伙伴可以了解下。

实现思路

本文将实现一个跨平台的微信用户ID(wxid)获取工具,

DeviceUtils类提供静态方法能自动识别Windows、Linux和MacOS系统,从微信配置文件中提取已登录的wxid

  • Windows平台读取config.data文件
  • Linux/MacOS检查特定目录下的登录文件夹

CMDUtils类提供命令行执行功能,支持阻塞/非阻塞执行及实时输出处理

实现代码

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
import os
import platform
import re
from utils.utils_cmd import CMDUtils
class DeviceUtils:
"""
设备工具类
"""
@staticmethod
def get_wechat_wxid(folder=None):
"""
获取设备上登陆的 微信 wxid
:param folder:仅针对Windows平台自定义数据存储路径生效
:return:
"""
wxids = []
system = DeviceUtils().get_system()
if system == "Windows":
if not folder:
file = os.path.join(
os.environ['USERPROFILE'],
'Documents',
'WeChat Files',
'All Users',
'config',
'config.data'
)
else:
file = os.path.join(
folder,
'All Users',
'config',
'config.data'
)
with open(file, "rb") as f:
data = f.read()
data_matches = re.findall(r'(wxid_.*?)\\\\config', str(data))
if len(data_matches) > 0:
wxids.extend(data_matches)
elif system == "Linux":
user = CMDUtils.run_await_results(cmd=['whoami'])
for folder in ('文档', 'Documents'):
file = f'/home/{user}/{folder}/xwechat_files/all_users/login'
if os.path.exists(file):
file_list = os.listdir(file)
if len(file_list) > 0:
for filename in file_list:
if filename.startswith('wxid_'):
wxids.append(filename)
elif system == "Darwin":
user = CMDUtils.run_await_results(cmd=['whoami'])
file = f"/Users/{user}//Library/Containers/com.tencent.xinWeChat/Data/Documents/xwechat_files/all_users/login"
if os.path.exists(file):
file_list = os.listdir(file)
if len(file_list) > 0:
for filename in file_list:
if filename.startswith('wxid_'):
wxids.append(filename)
msg = f"{system} 识别到微信{len(wxids)}个" if len(wxids) > 0 else f"{system} 未识别到微信"
print(msg)
return wxids
@staticmethod
def get_system():
system = platform.system()
if system in ('Windows', 'Linux', 'Darwin'):
return system
return "Unsupported OS"
if __name__ == '__main__':
folder = input("input folder:")
print(DeviceUtils.get_wechat_wxid(folder))
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
83
84
85
86
87
88
89
90
91
92
93
# !/usr/bin/python3
# -*- coding:utf-8 -*-
"""
@author: JHC000abc@gmail.com
@file: utils_cmd.py
@time: 2025/7/8 21:53
@desc:
"""
import subprocess
from typing import Union, List, Callable, Optional
import threading
class CMDUtils:
"""
"""
@staticmethod
def run_await_results(cmd: Union[str, List[str]],
timeout: Optional[int] = None) -> str:
"""
阻塞执行命令并返回结果(自动剥离首尾空格)
:param cmd: 命令(字符串或列表形式)
:param timeout: 超时时间(秒)
:return: 命令输出(stdout 或 stderr)
:raises: subprocess.CalledProcessError 当命令返回非零状态码时
"""
result = subprocess.run(
cmd,
capture_output=True,
text=True,
check=True,
shell=isinstance(cmd, str),
timeout=timeout
)
return result.stdout.strip()
@staticmethod
def run_background(cmd: Union[str, List[str]],
**kwargs) -> subprocess.Popen:
"""
后台非阻塞执行命令
:param cmd: 命令(字符串或列表形式)
:param kwargs: 传递给 subprocess.Popen 的额外参数
:return: Popen 对象(可通过 returncode 属性检查状态)
"""
return subprocess.Popen(
cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
shell=isinstance(cmd, str),
**kwargs
)
@staticmethod
def run_realtime_output(cmd: Union[str, List[str]],
output_handler: Callable[[str], None] = print,
**kwargs) -> subprocess.Popen:
"""
实时输出命令执行结果(非阻塞)
:param cmd: 命令(字符串或列表形式)
:param output_handler: 自定义输出处理函数(默认打印到控制台)
:param kwargs: 传递给 subprocess.Popen 的额外参数
:return: Popen 对象
"""
def _enqueue_output(pipe, handler):
for line in iter(pipe.readline, ''):
handler(line.strip())
pipe.close()
proc = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
shell=isinstance(cmd, str),
**kwargs
)
# 启动独立线程处理输出
threading.Thread(
target=_enqueue_output,
args=(proc.stdout, output_handler),
daemon=True
).start()
return proc

知识扩展

Python实现微信导出群成员WXID

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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
import tkinter as tk
from tkinter import ttk
from tkinter import messagebox
import threading
import requests
import json
import time
import base64
import io
try:
from PIL import Image, ImageTk
PIL_AVAILABLE = True
except ImportError:
PIL_AVAILABLE = False
# 全局变量定义
token_id = None        # 接口Token
app_id = None          # 设备ID(appId)
logged_in = False      # 是否已登录
account_nick = None    # 登录账户昵称(用于提示)
user_wxid = None       # 登录账户的微信ID
# 初始化Tk窗口
root = tk.Tk()
root.title("Gewechat 工具")
root.geometry("800x600")
# 界面布局:登录区、群列表区、批量加好友区、日志区
login_frame = ttk.Frame(root, padding=5)
group_frame = ttk.Frame(root, padding=5)
friend_frame = ttk.Frame(root, padding=5)
log_frame = ttk.Frame(root, padding=5)
login_frame.grid(row=0, column=0, sticky="NSW")
group_frame.grid(row=0, column=1, sticky="NS")
friend_frame.grid(row=0, column=2, sticky="NS")
log_frame.grid(row=1, column=0, columnspan=3, sticky="NSEW")
root.grid_columnconfigure(0, weight=1)
root.grid_columnconfigure(1, weight=1)
root.grid_columnconfigure(2, weight=1)
root.grid_rowconfigure(1, weight=1)
# 登录区域
lbl_login_status = ttk.Label(login_frame, text="登录状态:未登录")
lbl_login_status.pack(pady=5)
qr_label = ttk.Label(login_frame, text="(请扫描二维码登录)", justify="center")
qr_label.pack()
# 群列表操作区域
group_buttons_frame = ttk.Frame(group_frame)
group_buttons_frame.pack(fill="x", pady=2)
btn_refresh_groups = ttk.Button(group_buttons_frame, text="获取群列表")
btn_export_members = ttk.Button(group_buttons_frame, text="导出群成员")
btn_refresh_groups.pack(side="left", padx=2)
btn_export_members.pack(side="left", padx=2)
group_listbox = tk.Listbox(group_frame, height=15)
scrollbar_groups = ttk.Scrollbar(group_frame, orient="vertical", command=group_listbox.yview)
group_listbox.config(yscrollcommand=scrollbar_groups.set)
group_listbox.pack(side="left", fill="y", expand=True)
scrollbar_groups.pack(side="left", fill="y")
# 批量加好友区域
friend_label = ttk.Label(friend_frame, text="批量加好友(每行一个ID):")
friend_label.pack(anchor="w")
friend_text = tk.Text(friend_frame, width=30, height=10)
friend_text.pack(fill="both", expand=True)
btn_add_friends = ttk.Button(friend_frame, text="开始添加好友")
btn_add_friends.pack(pady=5)
# 日志输出区域
log_label = ttk.Label(log_frame, text="日志输出:")
log_label.pack(anchor="w")
log_text = tk.Text(log_frame, height=8)
log_text.pack(side="left", fill="both", expand=True)
log_scroll = ttk.Scrollbar(log_frame, orient="vertical", command=log_text.yview)
log_text.config(yscrollcommand=log_scroll.set, state="normal")
log_scroll.pack(side="right", fill="y")
def log_message(message: str):
"""在日志文本框追加消息(超过500字截断)"""
truncated = message if len(message) <= 500 else message[:500] + "...(截断)"
def _append():
log_text.insert(tk.END, truncated + "\n")
log_text.see(tk.END)
root.after(0, _append)
def save_credentials():
"""将当前凭据保存到本地文件"""
cred = {"appId": app_id, "tokenId": token_id}
if user_wxid:
cred["wxid"] = user_wxid
try:
with open("gewe_cred.json", "w", encoding="utf-8") as f:
json.dump(cred, f, ensure_ascii=False, indent=4)
except Exception as e:
log_message(f"保存凭据失败: {e}")
def load_credentials():
"""从本地文件加载上次保存的凭据"""
global app_id, token_id
try:
with open("gewe_cred.json", "r", encoding="utf-8") as f:
cred = json.load(f)
app_id = cred.get("appId", "")
token_id = cred.get("tokenId", "")
except FileNotFoundError:
app_id = ""
token_id = ""
except Exception as e:
log_message(f"读取凭据异常: {e}")
app_id = ""
token_id = ""
def http_post(endpoint: str, data: dict):
"""发送POST请求到Gewechat API并返回结果JSON(同时日志记录请求和响应)"""
url = base_url + endpoint
try:
payload_str = json.dumps(data, ensure_ascii=False)
except Exception:
payload_str = str(data)
log_message(f"请求: POST {endpoint} {payload_str}")
headers = {"Content-Type": "application/json"}
if token_id:
headers["X-GEWE-TOKEN"] = token_id
try:
resp = requests.post(url, json=data, headers=headers, timeout=10)
except Exception as e:
log_message(f"请求异常: {e}")
return None
resp_text = resp.text
log_message(f"响应: {resp_text}")
try:
result = resp.json()
except Exception:
log_message("响应非JSON格式或解析失败")
return None
return result
def enable_ui_after_login():
"""登录成功后,启用各功能按钮,并更新登录状态显示"""
btn_refresh_groups.config(state="normal")
btn_export_members.config(state="normal")
btn_add_friends.config(state="normal")
status_text = "登录成功"
if account_nick:
status_text = f"已登录:{account_nick}"
lbl_login_status.config(text=status_text)
try:
qr_label.config(image="", text="")  # 清除二维码显示
except Exception:
pass
def login_process():
"""登录线程:检查在线状态或执行扫码登录"""
global logged_in, token_id, app_id, account_nick, user_wxid
# 1. 尝试使用已有token检查是否在线
if token_id:
result = http_post("/login/checkOnline", {"appId": app_id})
if result:
ret = result.get("ret")
data = result.get("data")
if (ret == 200 or ret == 0) and data is True:
# 当前已在线
logged_in = True
log_message("当前已在线,无需重复登录")
root.after(0, enable_ui_after_login)
return
# 2. 若不存在token或检查结果离线,获取新Token
if not token_id or (result and result.get("ret") in [-1, 401, 404, 500] or result is None):
log_message("获取新的Token...")
token_res = http_post("/tools/getTokenId", {})
if token_res:
if token_res.get("ret") in (200, 0):
new_token = token_res.get("data") or token_res.get("token") or token_res.get("tokenId")
if not new_token:
data_field = token_res.get("data")
if data_field and isinstance(data_field, dict):
new_token = data_field.get("token") or data_field.get("tokenId")
if new_token:
token_id = new_token
log_message("Token获取成功")
else:
log_message("Token获取失败: 未返回token值")
else:
log_message(f"获取Token失败: {token_res.get('msg')}")
else:
log_message("获取Token失败: 无响应")
if not token_id:
messagebox.showerror("登录失败", "无法获取Token,登录终止。")
return
# 3. 获取登录二维码
log_message("请求登录二维码...")
req_app_id = app_id if app_id else ""
payload = {"appId": req_app_id, "regionId": "320000"}
qr_res = http_post("/login/getLoginQrCode", payload)
if not qr_res or qr_res.get("ret") not in [200, 0]:
log_message(f"获取登录二维码失败: {qr_res.get('msg') if qr_res else '无响应'}")
messagebox.showerror("登录失败", "获取登录二维码失败,请检查服务器。")
return
qr_data = qr_res.get("data", {})
new_app_id = qr_data.get("appId", "")
if new_app_id:
app_id = new_app_id
log_message(f"使用设备ID: {app_id}")
uuid = qr_data.get("uuid")
if not uuid:
qr_link = qr_data.get("qrData")
if qr_link and "/x/" in qr_link:
uuid = qr_link.split("/x/")[-1]
qr_img_b64 = qr_data.get("qrImgBase64", "")
if qr_img_b64:
if qr_img_b64.startswith("data:image"):
comma_index = qr_img_b64.find("base64,")
if comma_index != -1:
qr_img_b64 = qr_img_b64[comma_index+7:]
try:
img_data = base64.b64decode(qr_img_b64)
if PIL_AVAILABLE:
image = Image.open(io.BytesIO(img_data))
tk_img = ImageTk.PhotoImage(image)
else:
tk_img = tk.PhotoImage(data=qr_img_b64)
def show_qr():
qr_label.config(image=tk_img)
qr_label.image = tk_img
lbl_login_status.config(text="请使用微信扫描二维码登录")
root.after(0, show_qr)
except Exception as e:
log_message(f"二维码显示失败: {e}")
# 4. 轮询检查扫码状态
log_message("等待扫码确认...")
start_time = time.time()
refresh_count = 0
while not logged_in and refresh_count < 2:
check_res = http_post("/login/checkLogin", {"appId": app_id, "uuid": uuid, "captchCode": ""})
if check_res:
ret = check_res.get("ret")
data = check_res.get("data", {})
if (ret == 200 or ret == 0) and data:
status = data.get("status")
if status == 0:
# 未扫码
pass
elif status == 1:
# 已扫码,待确认
nick = data.get("nickName")
if nick:
account_nick = nick
log_message(f"已扫码,等待确认登录... (微信昵称: {nick})")
elif status == 2:
# 登录成功
logged_in = True
login_info = data.get("loginInfo")
if login_info and isinstance(login_info, dict):
user_name = login_info.get("userName") or login_info.get("wxid")
if user_name:
log_message(f"登录账号ID: {user_name}")
user_wxid = user_name
if not account_nick:
account_nick = data.get("nickName") or (login_info.get("nickName") if login_info else None)
log_message("微信登录成功")
break
else:
err_msg = check_res.get("msg") or (check_res.get("data", {}).get("msg") if isinstance(check_res.get("data"), dict) else "")
log_message(f"登录检查失败: {err_msg}")
# 若超过约220秒未确认且未登录,尝试刷新二维码一次
if time.time() - start_time > 220 and not logged_in and refresh_count < 1:
log_message("二维码已过期,正在获取新的二维码...")
refresh_count += 1
start_time = time.time()
qr_res2 = http_post("/login/getLoginQrCode", {"appId": app_id, "regionId": "320000"})
if qr_res2 and (qr_res2.get("ret") == 200 or qr_res2.get("ret") == 0):
qr_data2 = qr_res2.get("data", {})
uuid = qr_data2.get("uuid") or uuid
qr_img_b64_new = qr_data2.get("qrImgBase64")
if qr_img_b64_new:
if qr_img_b64_new.startswith("data:image"):
idx = qr_img_b64_new.find("base64,")
if idx != -1:
qr_img_b64_new = qr_img_b64_new[idx+7:]
try:
img_data = base64.b64decode(qr_img_b64_new)
if PIL_AVAILABLE:
image = Image.open(io.BytesIO(img_data))
tk_img2 = ImageTk.PhotoImage(image)
else:
tk_img2 = tk.PhotoImage(data=qr_img_b64_new)
def update_qr():
qr_label.config(image=tk_img2)
qr_label.image = tk_img2
root.after(0, update_qr)
except Exception as e:
log_message(f"新二维码显示失败: {e}")
log_message("请扫描新的二维码")
else:
log_message("无法刷新二维码,登录失败")
break
time.sleep(2)
if not logged_in:
log_message("登录超时或失败")
messagebox.showwarning("登录失败", "二维码超时,请重新运行程序重试。")
return
# 5. 登录成功后,启用功能并保存凭据
root.after(0, enable_ui_after_login)
save_credentials()
# 获取群列表线程函数
def refresh_groups():
global group_ids
log_message("获取通讯录列表...")
res = http_post("/contacts/fetchContactsList", {"appId": app_id})
if not res or res.get("ret") not in [0, 200]:
log_message("获取通讯录列表失败")
root.after(0, lambda: messagebox.showerror("错误", "获取群列表失败"))
return
data = res.get("data", {})
chatrooms = data.get("chatrooms", [])
if not chatrooms:
log_message("未获取到任何群聊")
root.after(0, lambda: messagebox.showinfo("结果", "通讯录中没有群聊"))
return
log_message(f"获取到{len(chatrooms)}个群ID,正在获取群名称...")
# 获取群/好友简要信息以获得群名称
info_res = http_post("/contacts/getContactInfo", {"appId": app_id, "userNames": chatrooms})
group_name_list = []
group_ids = []
if info_res and (info_res.get("ret") == 0 or info_res.get("ret") == 200):
info_data = info_res.get("data")
if info_data:
if isinstance(info_data, list):
infos = info_data
elif isinstance(info_data, dict) and info_data.get("contacts"):
infos = info_data.get("contacts")
elif isinstance(info_data, dict):
infos = []
for val in info_data.values():
if isinstance(val, dict):
infos.append(val)
else:
infos = []
for info in infos:
name = info.get("nickName") or info.get("userName")
uid = info.get("userName") or info.get("wxid")
if name:
group_name_list.append(name)
group_ids.append(uid)
else:
group_name_list = chatrooms
group_ids = chatrooms
def update_listbox():
group_listbox.delete(0, tk.END)
for name in group_name_list:
group_listbox.insert(tk.END, name)
root.after(0, update_listbox)
log_message("群列表更新完成")
# 启动群成员导出线程(由按钮触发)
def start_refresh_groups():
threading.Thread(target=refresh_groups, daemon=True).start()
def start_export_members():
# 主线程读取选中项
sel = group_listbox.curselection()
if not sel:
messagebox.showinfo("提示", "请先选择一个群组")
return
index = sel[0]
if index >= len(group_ids):
messagebox.showerror("错误", "群组选择无效")
return
gid = group_ids[index]
gname = group_listbox.get(index)
def export_thread(group_id, group_name):
log_message(f"正在导出群成员: {group_name} ({group_id})")
res = http_post("/group/getChatroomMemberList", {"appId": app_id, "chatroomId": group_id})
if not res or res.get("ret") not in [0, 200]:
log_message("获取群成员列表失败")
root.after(0, lambda: messagebox.showerror("错误", f"获取群成员失败: {res.get('msg') if res else '无响应'}"))
return
data = res.get("data", {})
members = []
if data:
if "memberList" in data:
members = data["memberList"]
elif "members" in data and isinstance(data["members"], list) and data["members"] and isinstance(data["members"][0], dict):
members = data["members"]
elif isinstance(data, list):
members = data
if not members:
log_message("群成员列表为空或解析失败")
root.after(0, lambda: messagebox.showinfo("提示", "未获取到群成员信息"))
return
safe_name = "".join([c if c not in r'\/:*?"<>|' else "_" for c in group_name])
if not safe_name:
safe_name = group_id.replace("@chatroom", "")
filename = f"{safe_name}_members.csv"
try:
with open(filename, "w", encoding="utf-8-sig") as f:
f.write("微信ID,昵称\n")
for member in members:
wxid_val = member.get("wxid") or member.get("userName") or ""
nick_val = member.get("nickName") or ""
wxid_val = str(wxid_val).replace(",", " ")
nick_val = str(nick_val).replace(",", " ")
f.write(f"{wxid_val},{nick_val}\n")
log_message(f"群成员已导出到文件: {filename}")
root.after(0, lambda: messagebox.showinfo("导出完成", f"群成员列表已保存至 {filename}"))
except Exception as e:
log_message(f"导出文件写入失败: {e}")
root.after(0, lambda: messagebox.showerror("错误", f"导出文件失败: {e}"))
threading.Thread(target=export_thread, args=(gid, gname), daemon=True).start()
def start_add_friends():
# 主线程获取文本框内容
lines = friend_text.get("1.0", tk.END).strip().splitlines()
ids_to_add = [line.strip() for line in lines if line.strip()]
if not ids_to_add:
messagebox.showinfo("提示", "请在文本框中输入要添加的好友ID,每行一个")
return
verify_message = "你好,我是通过群聊添加您为好友。"
def add_thread(id_list):
for wxid in id_list:
log_message(f"搜索好友: {wxid}")
search_res = http_post("/contacts/search", {"appId": app_id, "contactsInfo": wxid})
if not search_res or search_res.get("ret") not in [0, 200]:
log_message(f"搜索失败: 无法找到 {wxid}")
continue
search_data = search_res.get("data", {})
v3 = search_data.get("v3")
v4 = search_data.get("v4")
nick = search_data.get("nickName")
if not v3 or not v4:
log_message(f"无法添加 {wxid}: 未获取到v3/v4")
continue
log_message(f"发送好友申请给 {wxid} (昵称: {nick})")
add_payload = {"appId": app_id, "v3": v3, "v4": v4, "scene": 3, "content": verify_message, "option": 2}
add_res = http_post("/contacts/addContacts", add_payload)
if add_res and (add_res.get("ret") == 0 or add_res.get("ret") == 200):
log_message(f"已发送好友请求给 {wxid}")
else:
msg = add_res.get("msg") if add_res else "无响应"
log_message(f"添加好友失败: {wxid} - {msg}")
root.after(0, lambda: messagebox.showinfo("完成", "批量加好友操作完成,请查看日志获取详情。"))
threading.Thread(target=add_thread, args=(ids_to_add,), daemon=True).start()
# 将按钮点击事件绑定到相应线程启动函数
btn_refresh_groups.config(command=start_refresh_groups, state="disabled")
btn_export_members.config(command=start_export_members, state="disabled")
btn_add_friends.config(command=start_add_friends, state="disabled")
# 设置Gewechat服务的API地址(本地默认端口2531)
base_url = "http://192.168.175.145:2531/v2/api"
group_ids = []  # 全局群ID列表(与列表框序号对应)
# 尝试使用已保存的凭据自动登录,然后启动登录线程
load_credentials()
threading.Thread(target=login_process, daemon=True).start()
root.mainloop()

到此这篇关于使用Python实现获取本机当前用户登陆过的微信ID的文章就介绍到这了。

 

 

学习资料见知识星球。

以上就是今天要分享的技巧,你学会了吗?若有什么问题,欢迎在下方留言。

快来试试吧,小琥 my21ke007。获取 1000个免费 Excel模板福利​​​​!

更多技巧, www.excelbook.cn

欢迎 加入 零售创新 知识星球,知识星球主要以数据分析、报告分享、数据工具讨论为主;

Excelbook.cn Excel技巧 SQL技巧 Python 学习!

你将获得:

1、价值上万元的专业的PPT报告模板。

2、专业案例分析和解读笔记。

3、实用的Excel、Word、PPT技巧。

4、VIP讨论群,共享资源。

5、优惠的会员商品。

6、一次付费只需129元,即可下载本站文章涉及的文件和软件。

文章版权声明 1、本网站名称:Excelbook
2、本站永久网址:http://www.excelbook.cn
3、本网站的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系站长王小琥进行删除处理。
4、本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
5、本站一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报。
6、本站资源大多存储在云盘,如发现链接失效,请联系我们我们会第一时间更新。

THE END
分享
二维码
< <上一篇
下一篇>>