当前位置: 首页 > article >正文

用Python在QQ群里中快速发消息,以及连点器的制作

因为在QQ群里中发消息实在是太慢了 所以我定得用python制作一个能够快速发送消息的脚本具体内容如下:

先上总代码:

import sys
import tkinter as tk
import pyautogui
import time
import threading
import keyboard as keys
import os
from pynput import keyboard
# import ttkbootstrap as ttk
from playsound import playsound
import randomauto_times = 1  # 自动脚本执行次数
auto_rest = 0.1  # 自动脚本每次点击间隔时间
Copy_times = 1  # 复制消息发送次数
Click_times = 1  # 连点器点击次数
Click_rest = 0.1  # 连点器每次点击间隔时间
random_list = [1, 2, 3]  # 随机数字列表def play_prompt_sound(file_path):MyThread(playsound, file_path)def get_current_time_string():global current_time_string  # 声明要在函数内部使用全局变量while True:current_time = time.localtime()  # 获取当前时间的时间结构current_time_string = "[" + time.strftime("%H:%M:%S",current_time) + "]"  # 格式化时间为字符串time.sleep(1)  # 等待1秒def Send_Copy():global current_time_stringplay_prompt_sound("C:\\Windows\\Media\\Windows Notify Messaging.wav")time.sleep(3)pyautogui.PAUSE = 0.015  # 每次点击的间隔时间 若QQ崩溃则调大该数值即可 该数值与发送速度成反比while True:if keys.is_pressed("F10"):  # 按下F10结束发送print(current_time_string + '已结束QQ消息发送')breakpyautogui.click(125, 977)  # 点击第一处位置pyautogui.hotkey('ctrl', 'v')  # 粘贴randfigure = random.choice(random_list)  # 随机字符输入if randfigure == 1:pyautogui.press('.')if randfigure == 2:pyautogui.press('。')if randfigure == 3:pyautogui.press(',')pyautogui.click(1644, 1025)  # 点击第二处位置def Click():  # 连点器函数global Click_rest, Click_timesClick_times = int(entry_Click_times.get())Click_rest = float(entry_Click_rest.get())  # 刷新次数和间隔pyautogui.PAUSE = 0.015def on_press(key):if key == keyboard.Key.f9:  # 按下f9开始连点器for i in range(Click_times):pyautogui.click()time.sleep(Click_rest)with keyboard.Listener(on_press=on_press) as listener:listener.join()def Auto_Edit():play_prompt_sound("C:\\Windows\\Media\\Windows Notify Messaging.wav")global figurefigure = 0try:os.remove('1.xml')print(current_time_string + '删除上次配置')except:print(current_time_string + '创建配置')print(current_time_string + '开始记录脚本位置')spam = []def on_press(key):if key == keyboard.Key.home:  # 按下home键开始记录点击位置global figurefigure = figure + 1a1 = pyautogui.position()a2 = [a1.x, a1.y]spam.append(a2)print(current_time_string + f'第{figure}处位置设置成功')play_prompt_sound("C:\\Windows\\Media\\Windows Notify Email.wav")def on_release(key):if key == keyboard.Key.end:  # 按下end键结束记录if not spam:print(current_time_string + '本次未记录点击位置')pyautogui.confirm('未记录点击位置')sys.exit()so = open('1.xml', 'w')for c in range(0, len(spam)):so.write(f'{spam[c]}\n')so.close()print(current_time_string + '结束设置')play_prompt_sound("C:\\Windows\\Media\\Windows Message Nudge.wav")sys.exit()with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:listener.join()  # 热键监听def Auto_Click():play_prompt_sound("C:\\Windows\\Media\\Windows Notify Messaging.wav")global current_time_string, auto_restshu = os.path.exists('1.xml')spam1 = []auto_rest = float(entry_Auto_rest.get())auto_times = int(entry_Auto_times.get())if not shu:print(current_time_string + '未找到数据')  # 未找到xml文件 暂停函数pyautogui.confirm('未找到数据')sys.exit()with open("1.xml") as lines:for line in lines:spam1.append(eval(line))if not spam1:print(current_time_string + '未找到数据')  # xml中无数据 暂停函数pyautogui.confirm('未找到数据')sys.exit()time.sleep(2)pyautogui.PAUSE = 0.005i1 = 0for x in range(auto_times):  # 脚本次数for i in range(0, len(spam1)):  # 获取ldq列表的长度 决定点击次数i1 = i1 + 1pyautogui.click(spam1[i])  # 依次点击time.sleep(auto_rest)print(current_time_string + f'第{i + 1}处位置点击成功')  # 点击状态提示class MyThread(threading.Thread):  # 多线程封装  没有这部分tkinter会无法响应def __init__(self, func, *args):super().__init__()self.func = funcself.args = argsself.setDaemon(True)self.start()  # 在这里开始def run(self):self.func(*self.args)thread = threading.Thread(target=get_current_time_string)
thread.daemon = True
thread.start()
win = tk.Tk()  # 利用ttk库创建tk窗口
# win = ttk.Window()  # 利用ttk库创建tk窗口
# style = ttk.Style('litera')   # 窗口风格为litera
win.title('连点器')  # 窗口标题
win.geometry('400x200')  # 窗口大小(500x300)
win.resizable(False, False)  # 窗口大小不可改变
# win.wm_attributes("-topmost", 1)  # 窗口置顶
Button_Copy = tk.Button(win, text='发送(复制内容)', command=lambda: MyThread(Send_Copy), width=22)
Button_Copy.pack()  # 绘制按钮 下同
Button_Copy.place(x=0, y=130)  # 用place布局 下同
Q_Label = tk.Label(win, text='QQ消息:', width=22)
Q_Label.pack()
Q_Label.place(x=0, y=110)
Button_Click = tk.Button(win, text='连点器', command=lambda: MyThread(Click), width=22)
Button_Click.pack()
Button_Click.place(x=200, y=60)
Label_Click_times = tk.Label(win, text='连点器执行次数:')
Label_Click_times.pack()
Label_Click_times.place(x=200, y=0)
Label_Click_rest = tk.Label(win, text='每次点击间隔时间:')
Label_Click_rest.pack()
Label_Click_rest.place(x=200, y=30)
entry_Click_times = tk.Entry(win, width=5)  # 连点器点击次数
entry_Click_times.pack()
entry_Click_times.place(x=320, y=0)
entry_Click_times.insert(0, str(Click_times))
entry_Click_rest = tk.Entry(win, width=5)  # 连点器每次点击时间
entry_Click_rest.pack()
entry_Click_rest.place(x=320, y=30)
entry_Click_rest.insert(0, str(Click_rest))
Label_Auto_times = tk.Label(win, text='自动脚本执行次数:')
Label_Auto_times.pack()
Label_Auto_times.place(x=0, y=0)
Label_Auto_rest = tk.Label(win, text='每次点击间隔时间:')
Label_Auto_rest.pack()
Label_Auto_rest.place(x=0, y=30)
# 创建一个Entry部件用于输入文本
entry_Auto_times = tk.Entry(win, width=5)  # 自动脚本执行次数
entry_Auto_times.pack()
entry_Auto_times.place(x=120, y=0)
entry_Auto_times.insert(0, str(auto_times))
entry_Auto_rest = tk.Entry(win, width=5)  # 自动脚本每次点击时间
entry_Auto_rest.pack()
entry_Auto_rest.place(x=120, y=30)
entry_Auto_rest.insert(0, str(auto_rest))
Auto_Record = tk.Button(win, text='记录自动脚本', command=lambda: MyThread(Auto_Edit))
Auto_Record.pack()
Auto_Record.place(x=0, y=60)
Auto_Run = tk.Button(win, text='执行自动脚本', command=lambda: MyThread(Auto_Click))
Auto_Run.pack()
Auto_Run.place(x=80, y=60)print(current_time_string + '窗口创建成功')win.mainloop()

 运行效果图:

因为我的显示器是1920x1080的 所以我的点击位置为上图所示 大家可以在python控制台中输入pyautogui.mouseInfo()来查看鼠标位置 

在QQ群中快速发消息的原理:点击消息框>粘贴内容>点击发送按钮 这样就完成了发消息 这样就实现了快速发消息 可以算是脚本或是宏之类的

自动脚本的记录就是当按下一次按键时 向文件中写入做坐标数据 当下次执行自动脚本时 从文件中读取坐标数据来进行点击 

[23, 917]
[54, 695]
1.xml文件中的坐标数据

这一部分是用来创建窗口的:

win = tk.Tk()  # 利用ttk库创建tk窗口
# win = ttk.Window()  # 利用ttk库创建tk窗口
# style = ttk.Style('litera')   # 窗口风格为litera
win.title('连点器')  # 窗口标题
win.geometry('400x200')  # 窗口大小(500x300)
win.resizable(False, False)  # 窗口大小不可改变
# win.wm_attributes("-topmost", 1)  # 窗口置顶
Button_Copy = tk.Button(win, text='发送(复制内容)', command=lambda: MyThread(Send_Copy), width=22)
Button_Copy.pack()  # 绘制按钮 下同
Button_Copy.place(x=0, y=130)  # 用place布局 下同
Q_Label = tk.Label(win, text='QQ消息:', width=22)
Q_Label.pack()
Q_Label.place(x=0, y=110)
Button_Click = tk.Button(win, text='连点器', command=lambda: MyThread(Click), width=22)
Button_Click.pack()
Button_Click.place(x=200, y=60)
Label_Click_times = tk.Label(win, text='连点器执行次数:')
Label_Click_times.pack()
Label_Click_times.place(x=200, y=0)
Label_Click_rest = tk.Label(win, text='每次点击间隔时间:')
Label_Click_rest.pack()
Label_Click_rest.place(x=200, y=30)
entry_Click_times = tk.Entry(win, width=5)  # 连点器点击次数
entry_Click_times.pack()
entry_Click_times.place(x=320, y=0)
entry_Click_times.insert(0, str(Click_times))
entry_Click_rest = tk.Entry(win, width=5)  # 连点器每次点击时间
entry_Click_rest.pack()
entry_Click_rest.place(x=320, y=30)
entry_Click_rest.insert(0, str(Click_rest))
Label_Auto_times = tk.Label(win, text='自动脚本执行次数:')
Label_Auto_times.pack()
Label_Auto_times.place(x=0, y=0)
Label_Auto_rest = tk.Label(win, text='每次点击间隔时间:')
Label_Auto_rest.pack()
Label_Auto_rest.place(x=0, y=30)
# 创建一个Entry部件用于输入文本
entry_Auto_times = tk.Entry(win, width=5)  # 自动脚本执行次数
entry_Auto_times.pack()
entry_Auto_times.place(x=120, y=0)
entry_Auto_times.insert(0, str(auto_times))
entry_Auto_rest = tk.Entry(win, width=5)  # 自动脚本每次点击时间
entry_Auto_rest.pack()
entry_Auto_rest.place(x=120, y=30)
entry_Auto_rest.insert(0, str(auto_rest))
Auto_Record = tk.Button(win, text='记录自动脚本', command=lambda: MyThread(Auto_Edit))
Auto_Record.pack()
Auto_Record.place(x=0, y=60)
Auto_Run = tk.Button(win, text='执行自动脚本', command=lambda: MyThread(Auto_Click))
Auto_Run.pack()
Auto_Run.place(x=80, y=60)print(current_time_string + '窗口创建成功')win.mainloop()

http://www.lryc.cn/news/2412911.html

相关文章:

  • 十大经典策略之一 - Dual Thrust策略(期货)
  • 计算机毕业设计 asp.net精品课程网站 毕设
  • 一位老工程师的忠告
  • 软件工程期末考试题库(超全)
  • 最新Android架构师成长路线,,安卓已死
  • 毕业以后读书报告(不定时更新)
  • VC++适合做什么
  • Linux调试工具
  • Windows XP中的命令行命令
  • 关于visual studio 2005的中文版下载(最新详细下载点)
  • Bolt引擎内置的元对象介绍
  • 导航网站WP主题BlackCandy酷黑色高逼格
  • android 休眠唤醒机制分析(二) — early_suspend
  • HEAP: Free Heap block 0000028A24DF5A10 modified at 0000028A24DF5A50 after it was freed 正确解决方法
  • 将Lumaqq移植到Android中
  • Wireshark入门-Wireshark
  • 团队博客创建
  • 浅谈显 ipqq 发展历程 【附显 ipqq原理】
  • android gallery效果,Android RecyclerView封装的Gallery效果控件,android galleryview
  • MOS管场效应管构成的基本放大电路(等效的过程、gm的推导、基本共漏源极输出器、基本共源、对比三极管)
  • 单片机交通灯的电路图以及代码_proteus单片机仿真精彩动图(第二弹)
  • 盒式交换机VSU配置(适用于非11.X软件平台)
  • 自定义springboot组件--基于redisson实现分布式锁
  • RabbitMQ--基础--02--原理
  • 【云服务器搭建游戏私服】全流程
  • android dat怎么打开方式,Android 5.0 system.new.dat解包工具及方法
  • Teleport Pro使用教程
  • 用R抓取拉手网深圳地区的美食数据--增加商店地址信息
  • Matlab中句柄类和值类的比较
  • flash builder 4 编译器参数