繁体   English   中英

如何在垃圾邮件机器人中设置停止按钮?

[英]How can i make a stop button in my spam bot?

我想在我的垃圾邮件机器人中制作一个停止按钮。

我已经尝试制作一个停止循环的按钮

if (self) == 8:
    break 

但这不起作用,因为当我运行这个程序时它卡住了,所以当我点击它时它会崩溃。

from tkinter import *
import pyautogui
import time
import multiprocessing

root = Tk()
e = Entry(root)

root.geometry('800x800')

while 1 == 1:
    class SpamBot:
        def egal(lol):
            if lol == 1:
                maschiene = 1
                sekunden = input('wieviele sekunden?')
                while maschiene < sekunden:
                    maschiene
                    time.sleep(10)
                    f = open("meemovie.txt", 'r')
                    for word in f:
                        pyautogui.typewrite(word)
                        pyautogui.press("enter")


        def personal(lol):
            if lol == 2:
                spam = input('spam nachricht?')
                oft = int(input('wie oft? (max 2147483647) oder für unendlich die 1 drücken'))
                time.sleep(10)
                hallo = 1
                if oft == 1:
                    while 1 == 1:
                        pyautogui.typewrite(spam)
                        pyautogui.press("enter")
                while hallo < oft:
                    hallo = hallo + 1
                    pyautogui.typewrite(spam)
                    pyautogui.press("enter")

        def Rickspam(lol):
            if lol == 3:
                time.sleep(10)
                stop = input('klicke hier um zu stoppen')
                while 1 == 1:
                    if not stop == 'ksjhaddftgtgtqwertzuio':
                        break
                    f = open('jetztaber', 'r')
                    stop = input('klicke hier um zu stoppen')
                    for word in f:
                        pyautogui.typewrite(word)
                        pyautogui.press("enter")
                        stop = input('hallo')

        def Muffin(self):
            if self == 4:

                time.sleep(10)
                while 1 == 1:
                    f = open('Muffin', 'r')
                    for word in f:
                        pyautogui.typewrite(word)
                        pyautogui.press("enter")

        def ey(self):
            if self == 5:
                time.sleep(10)
                hallo = 1

                while hallo < 100:
                    hallo = hallo + 1
                    pyautogui.typewrite('Ey weist du was?')
                    pyautogui.press("enter")
            pyautogui.typewrite('Ach vergiss es ')
            pyautogui.press("enter")

        def bigwiggle(self):
            if self == 6:
                time.sleep(10)
                while 1 == 1:
                    f = open('bigwiggle.txt', 'r')
                    for word in f:
                        pyautogui.typewrite(word)
                        pyautogui.press("enter")

        def deja(self):
            if self == 7:
                time.sleep(10)
                while 1 == 1:
                    f = open('deja vu .txt', 'r')
                    for word in f:
                        pyautogui.typewrite(word)
                        pyautogui.press("enter")


    button1 = Button(root, text="Beemovie", command=lambda: SpamBot.egal(1), padx=50, pady=30)
    button1.place(x=200, y=0)

    button2 = Button(root, text="Personal Spam", command=lambda: SpamBot.personal(2), padx=45, pady=30)
    button2.place(x=0, y=0)

    button3 = Button(root, text="Rick spam", command=lambda: SpamBot.Rickspam(3), padx=45, pady=30)
    button3.place(x=400, y=0)

    button4 = Button(root, text="Muffin time", command=lambda: SpamBot.Muffin(4), padx=45, pady=30)
    button4.place(x=600, y=0)

    button5 = Button(root, text="Ey?", command=lambda: SpamBot.ey(5), padx=45, pady=30)
    button5.place(x=0, y=100)

    button6 = Button(root, text="BIg wiggle", command=lambda: SpamBot.bigwiggle(6), padx=45, pady=30)
    button6.place(x=150, y=100)

    button7 = Button(root, text="deja vu", command=lambda: SpamBot.deja(7), padx=45, pady=30)
    button7.place(x=350, y=100)

    root.mainloop()

使用键盘库:

安装:

pip3 install keyboard

用法:

if keyboard.is_pressed('a'):
   exit()

或者,如果您希望在 while 循环中使用它:

running = True

while running:
    if keyboard.is_pressed('a'):
        running = False

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM