Python 制作GUI界面实现消息轰炸

Python 制作GUI界面实现消息轰炸

话不多说,直接上代码

# -*- coding:utf-8 -*-
# Author:    吴铭公子
# Time  :    2021/5/24 11:10
# File  :    pynput1.py
import time
from pynput.mouse import Button, Controller as mouse_c
from pynput.keyboard import Key, Controller as key_c
import tkinter as tk
from functools import partial



# 键盘控制
def keyboardinput(string):
    keyboard = key_c()
    keyboard.type(string)


# 鼠标控制
def mouseclick():
    mouse = mouse_c()
    mouse.press(Button.left)
    mouse.release(Button.left)


# 响应函数
def response(string, number):
    string = string.get()
    number = number.get()
    time.sleep(5)
    for num in range(int(number)):
        keyboardinput(string)
        mouseclick()
        time.sleep(0.3)


# Tkinter创建的GUI界面
def main():
    root = tk.Tk()
    root.geometry('300x165+500+300')
    root.resizable(width=0, height=0)
    root.title('消息轰炸工具.exe')

    text = tk.StringVar()
    count = tk.StringVar()

    label1 = tk.Label(master=root, text="发送内容:", font=("黑体", 13))
    label1.grid(row=0, column=0, pady=15, padx=10)

    label2 = tk.Label(master=root, text="发送次数:", font=("黑体", 13))
    label2.grid(row=1, column=0, pady=5, padx=10)

    entry_text = tk.Entry(master=root, textvariable=text)
    entry_text.grid(row=0, column=1, ipadx=16, ipady=3)

    entry_count = tk.Entry(master=root, textvariable=count)
    entry_count.grid(row=1, column=1, ipadx=16, ipady=3)

    send_message = partial(response, text, count)
    send_button = tk.Button(master=root, text="发送", padx=90, pady=10, command=send_message)
    send_button.grid(row=3, column=0, columnspan=2, pady=15)

    root.mainloop()


if __name__ == '__main__':
    main()

运行效果

posted @ 2021-05-25 10:51  廿九九  阅读(263)  评论(0)    收藏  举报