Python implements automatic message sending

Prepare:

Install the pyautogui and pyperclip libraries. pyautogui can automatically control the keyboard and mouse, and pyperclip can control the clipboard.

 

Code:

import pyautogui
#控制键盘鼠标
import  pyperclip
#控制电脑的复制截切板
import  time
time.sleep(5)
#等待5秒后开始执行下面的代码
words="哦宝子"
#要发送的信息
for i in words.split("/n")*20:
#20个words拼接的字符串,再按照每个words进行划分,即i=words循环20次
    print(i)
    pyautogui.click(500,650)
    #把发送窗口放在范围内,鼠标自动识别点击位置
    pyperclip.copy(i)
    #复制一份i
    pyautogui.hotkey("ctrl","v")
    #粘贴在鼠标点击的窗口中
    pyautogui.typewrite("\n")
    #回车发送
    time.sleep(0.5)

 

Guess you like

Origin blog.csdn.net/weixin_46031067/article/details/117794023