Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
added GUI with start/stop button.
  • Loading branch information
tailllie committed Nov 30, 2023
1 parent 5aa55d4 commit ce7b487
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,44 @@
import pyautogui as pag
from tkinter import *
import random
import time
import threading

while True:
x = random.randint(200,500)
y = random.randint(300,600)
pag.moveTo(x,y,0.5)
time.sleep(2)

duration = 0.2 # duration of cursor movement
interval = 10 # interval between cursor movements


def run_script():
while script_running:
x = random.randint(250, 375)
y = random.randint(375, 450)
pag.moveTo(x, y, duration)
time.sleep(interval)

def toggle_script():
global script_running
script_running = not script_running
if script_running:
button.config(text="Stop")
# start script on other thread
script_thread = threading.Thread(target=run_script)
script_thread.start()
else:
button.config(text="Start")

# app window
root = Tk()
root.title("SuperPower")
root.geometry("100x50")

# frame for center
center_frame = Frame(root)
center_frame.pack(expand=True, fill="both")

# button
script_running = False
button = Button(center_frame, text="Start", command=toggle_script)
button.pack(pady=15)

root.mainloop()

0 comments on commit ce7b487

Please sign in to comment.