Python实现快速发送消息
微信关注公众号:夜寒信息
致力于为每一位用户免费提供更优质技术帮助与资源供给,感谢支持!
短短几行代码如何做到快速发送QQ消息、微信消息以及其他消息呢,今天给大家介绍分享我写的一个很短的源码,实现QQ快速发消息。
首先我们需要一个time库来设定延迟,不然速度太快
我们使用import time
其次我们需要引入pynput外设监听的库,来实现鼠标的点击、释放,及键盘的敲击
我们使用from pynput import mouse, keyboard
这里我使用了一个easygui,来实现开始的控制,点击确认之后再开始发送消息,提高用户使用舒适度
我们使用import easygui as g
我们的程序使用了pynput库,它可以直接使用它的方法
keyboard.Controller.type('string')
我们只需改变string,输入自己想发的消息,即可发送自己想发的重复的消息。但在这里,我使用的是读入文本文件,这样可以更好的自定义不同的文本内容
以下是源码:
import time
from pynput import mouse, keyboard
import easygui as g
title = g.msgbox(msg="点击开始后先点击QQ对话框,然后再将鼠标移动到发送按钮上",title="QQ轰炸",ok_button="开始")
def send_mail():
time.sleep(5)
m_mouse = mouse.Controller()
m_keyboard = keyboard.Controller()
m_mouse.position = m_mouse.position
m_mouse.click(mouse.Button.left)
with open(r'情话.txt', 'r',encoding = 'utf-8') as text:
for line in text.readlines():
m_keyboard.type(line)
m_keyboard.press(keyboard.Key.enter)
m_keyboard.release(keyboard.Key.enter)
time.sleep(0.5)
send_mail()
我的源码本本文件和程序会打包放在这里,大家可以自主下载
https://ww.lanzous.com/ibgr1yj
若有问题请关注微信公众号"夜寒信息"
微信关注公众号:夜寒信息
致力于为每一位用户免费提供更优质技术帮助与资源供给,感谢支持!