代码拉取完成,页面将自动刷新
同步操作将从 Yoga/微信自动添加好友 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
"""
微信自动添加好友
"""
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("添加完成")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。