1 Star 0 Fork 2

陈炳安 / 微信自动添加好友

forked from Yoga / 微信自动添加好友 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
addfri.py 1.81 KB
AI 代码解读
一键复制 编辑 原始数据 按行查看 历史
Yoga 提交于 2023-01-29 12:13 . first commit
"""
微信自动添加好友
"""
import subprocess
import time
import xlrd2
import uiautomation as auto
'''
待添加好友文件地址
文件第一列为电话号码,第二列为姓名
'''
infor = xlrd2.open_workbook("C:/Users/1.1/Desktop/工作簿1.xlsx")
sheet = infor.sheet_by_name("Sheet1")
phonenumbers=sheet.col_values(1)
name=sheet.col_values(0)
'''
微信安装路径
'''
subprocess.Popen('D:\微信\WeChat\WeChat.exe')
wechatWindow = auto.WindowControl(searchDepth=1, className='WeChatMainWndForPC', Name='微信')
for a, j in zip(name,phonenumbers):
k = int(j)
i = str(k)
messageText0 = wechatWindow.ButtonControl(Name='聊天')
messageText0.Click()
messageText0.Click()
messageText1=wechatWindow.ButtonControl(Name='通讯录')
messageText1.Click()
messageText2=wechatWindow.ButtonControl(Name='添加朋友')
messageText2.Click()
search = wechatWindow.EditControl(Name='微信号/手机号')
search.Click()
try:
search.GetParentControl().GetChildren()[1].SendKeys(i)
time.sleep(0.1)
table=wechatWindow.TextControl(Name=i)
table.Click()
pane=auto.PaneControl(Name='微信')
pane.Click()
button=pane.ButtonControl(Name='添加到通讯录')
button.Click()
except Exception as e:
print(a+i+"号码已添加或不能通过手机号加好友")
continue
try:
wechatWindow2 = auto.WindowControl(Name='添加朋友请求')
wechatWindow2.Click()
text1=wechatWindow2.EditControl(Name='')
text1.Click()
for k in range(20):
text1.SendKeys('{Back}',0.00001,0.00000001)
text1.SendKeys(a)
button2=wechatWindow2.ButtonControl(Name='确定')
button2.Click()
except Exception as e:
print('')
print("添加完成")
Python
1
https://gitee.com/cba6666/wechat-is-automatically-added.git
git@gitee.com:cba6666/wechat-is-automatically-added.git
cba6666
wechat-is-automatically-added
微信自动添加好友
master

搜索帮助