1.下载依赖库
需提前安装好python环境
pip3 install pyautogui -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip3 install pyperclip -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip3 install opencv-python -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
2.新建Start.py
import pyautogui
import pyperclip
import time
def get_msg():
"""想发的消息,每条消息空格分开"""
contents = "发送的内容 发送的内容"
return contents.split(" ")
def send(msg):
# 复制需要发送的内容到粘贴板
pyperclip.copy(msg)
# 模拟键盘 ctrl + v 粘贴内容
pyautogui.hotkey('ctrl', 'v')
# 发送消息
pyautogui.press('enter')
def send_msg(friend):
# Ctrl + alt + w 打开微信
pyautogui.hotkey('ctrl', 'alt', 'w')
# 搜索好友
pyautogui.hotkey('ctrl', 'f')
# 复制好友昵称到粘贴板
pyperclip.copy(friend)
# 模拟键盘 ctrl + v 粘贴
pyautogui.hotkey('ctrl', 'v')
time.sleep(1)
# 回车进入好友消息界面
pyautogui.press('enter')
# 一条一条发送消息
for msg in get_msg():
send(msg)
# 每条消息间隔 2 秒
time.sleep(2)
if __name__ == '__main__':
friend_name = "微信好友名"
send_msg(friend_name)
3.在Start.py同文件夹下新建Start.txt
python biu.py
后缀名改为bat
4.开启定时任务
1.创建任务
2.设置时间
3.设置路径为start.bat脚本路径
时间设置为当前时间后的一俩分钟,测试是否成功