循环运行时Tkinter没有响应!python

2024-06-07 19:29:24 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我只是在编写我可以用python编写的基本垃圾邮件程序。 但是,当我按下Tkinter窗口中的“垃圾邮件”按钮时,它不会响应,直到函数结束:(! 代码如下:

import pyautogui
import time
from tkinter import *
import keyboard
root = Tk()
root.geometry("300x250")

def retrive_input():
  inputValue = textBox.get("1.0","end-1c")
  spams(inputValue)
  print(inputValue)


textBox = Text(root,height=5,width=30)
textBox.grid(row=1)
buttonCommit = Button(root,height=1,width=10,text="Spam 
Word!",command=lambda:retrive_input())
buttonCommit.grid(row=2)


def spams(wordtospam):
  x_cor = 962
  y_cor=541
  pyautogui.click(962,541)
  for i in range(9999):
    pyautogui.press("enter")
    pyautogui.typewrite(wordtospam)
    pyautogui.press("enter")
    time.sleep(10)
    pyautogui.press("enter")
    pyautogui.typewrite('random stuff')
    pyautogui.press("enter")
    time.sleep(8)


upali = True



#spams('')

root.mainloop()

我还想添加一个按键检查,所以如果我按(例如)f5,程序将停止工作,直到我按f4。 谢谢你! (这是在游戏程序,将垃圾邮件我:),所以在游戏中键入你按回车,打字,回车和它发送)


Tags: import程序inputtimedef垃圾邮件rootpress

热门问题