This repository has been archived by the owner on Feb 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added GUI with start/stop button.
- Loading branch information
Showing
1 changed file
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |