下载地址:https://www.pan38.com/share.php?code=pvvmX 提取码:8888
声明:仅用于学习测试用途,请勿用于违规场景,作者对这款工具和相关代码拥有最终的解释权
通过微信自动加人脚本我们可以迅速的提高自己的好友通讯录数量,并且我们借助一些第三方插件还能让好友的数量翻倍,还可以实现营销的效果,让我们的产品销售给跟多的用户群体,那么这种插件是怎么实现大量加好友的效果呢,请看下面代码。
import time
import random
import uiautomation as auto
from typing import List, Dict
class WeChatAutoAdder:
def __init__(self):
self.wechat_window = auto.WindowControl(
Name="微信",
searchDepth=1
)
self.search_box = None
self.add_button = None
self._init_controls()
def _init_controls(self):
# 初始化微信窗口控件
self.search_box = self.wechat_window.EditControl(
Name="搜索",
foundIndex=1
)
def search_user(self, wxid: str) -> bool:
"""搜索指定微信号"""
try:
self.search_box.Click()
self.search_box.SendKeys(wxid)
time.sleep(2) # 等待搜索结果
return True
except Exception as e:
print(f"搜索失败: {e}")
return False
def add_contact(self, greeting: str = "") -> bool:
"""执行加好友操作"""
try:
add_btn = self.wechat_window.ButtonControl(
Name="添加到通讯录",
foundIndex=1
)
if add_btn.Exists():
add_btn.Click()
time.sleep(1)
# 处理验证消息
verify_input = self.wechat_window.EditControl(
Name="发送添加朋友申请",
foundIndex=1
)
if verify_input.Exists():
verify_input.SendKeys(greeting)
time.sleep(0.5)
# 点击发送按钮
send_btn = self.wechat_window.ButtonControl(
Name="发送",
foundIndex=1
)
send_btn.Click()
return True
return False
except Exception as e:
print(f"添加失败: {e}")
return False
def batch_add_users(self, wxids: List[str],
greetings: List[str] = None,
interval: int = 30) -> Dict[str, bool]:
"""批量添加用户"""
results = {}
for i, wxid in enumerate(wxids):
print(f"正在处理第 {i+1}/{len(wxids)} 个: {wxid}")
if self.search_user(wxid):
greeting = greetings[i] if greetings else ""
success = self.add_contact(greeting)
results[wxid] = success
time.sleep(random.randint(interval, interval+10))
else:
results[wxid] = False
return results
if __name__ == "__main__":
adder = WeChatAutoAdder()
# 示例用法
wxids = ["test123", "demo456"]
greetings = ["你好,我是王先生", "商务合作请联系"]
results = adder.batch_add_users(wxids, greetings)
print("执行结果:", results)
import json
import yaml
from typing import Dict, Any
class ConfigLoader:
@staticmethod
def load_json(file_path: str) -> Dict[str, Any]:
with open(file_path, 'r', encoding='utf-8') as f:
return json.load(f)
@staticmethod
def load_yaml(file_path: str) -> Dict[str, Any]:
with open(file_path, 'r', encoding='utf-8') as f:
return yaml.safe_load(f)
@staticmethod
def get_wxids_from_file(file_path: str) -> List[str]:
"""支持从txt/json/yaml加载微信号列表"""
if file_path.endswith('.txt'):
with open(file_path, 'r') as f:
return [line.strip() for line in f if line.strip()]
elif file_path.endswith('.json'):
data = ConfigLoader.load_json(file_path)
return data.get('wxids', [])
elif file_path.endswith('.yaml') or file_path.endswith('.yml'):
data = ConfigLoader.load_yaml(file_path)
return data.get('wxids', [])
raise ValueError("Unsupported file format")
random
import time
from datetime import datetime
class AntiDetect:
@staticmethod
def random_delay(base: int = 2, variance: int = 3) -> None:
"""随机延迟"""
time.sleep(base + random.random() * variance)
@staticmethod
def human_like_typing(text: str, cpm: int = 300) -> None:
"""模拟人类输入速度(字符/分钟)"""
delay_per_char = 60 / cpm
for char in text:
auto.SendKeys(char)
time.sleep(delay_per_char * (0.8 + 0.4 * random.random()))
@staticmethod
def random_mouse_movement():
"""随机移动鼠标防止检测"""
x, y = auto.GetCursorPos()
for _ in range(3):
new_x = x + random.randint(-50, 50)
new_y = y + random.randint(-50, 50)
auto.MoveTo(new_x, new_y, duration=0.2)
time.sleep(0.3)
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。