Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import threading
- from tkinter import *
- import pyautogui
- import random
- import keyboard
- root = Tk()
- root.title("Loop Terminate")
- time.sleep(0.5)
- stop = False
- def button_stop_command():
- # If the STOP button is pressed then terminate the loop
- global stop
- stop = True
- def button_start_command():
- global stop
- stop = False
- time.sleep(2)
- pyautogui.hotkey('win', 'd')
- while True and not stop:
- MouseX = random.randint(0, 1300)
- MouseY = random.randint(0, 700)
- MouseSleep = random.randint(1, 5)
- pyautogui.moveTo(MouseX, MouseY, duration=1)
- pyautogui.click()
- time.sleep(MouseSleep)
- def button_starter():
- t = threading.Thread(target=button_start_command)
- t.start()
- # Button START
- button_start = Button(root, text="START", padx=30, pady=20, command=button_starter)
- button_start.grid(columnspan=1, row=1,column=0)
- # Button STOP
- button_stop = Button(root, text="STOP", padx=33, pady=20, command=button_stop_command)
- button_stop.grid(row=2, column=0)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement