-
Notifications
You must be signed in to change notification settings - Fork 0
/
GUI (1440p).py
111 lines (95 loc) · 3.69 KB
/
GUI (1440p).py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import tkinter as tk
import pyautogui
import time
import random
import string
import keyboard
class App(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.master = master
self.pack()
self.create_widgets()
self.is_running = False
keyboard.add_hotkey('pause', self.stop_macro)
def create_widgets(self):
self.length_label = tk.Label(self, text="Length:")
self.length_label.pack(side="left")
self.length_entry = tk.Entry(self)
self.length_entry.pack(side="left")
self.iterations_label = tk.Label(self, text="Iterations:")
self.iterations_label.pack(side="left")
self.iterations_entry = tk.Entry(self)
self.iterations_entry.pack(side="left")
self.generate_button = tk.Button(self, text="Generate", command=self.generate)
self.generate_button.pack(side="left")
def generate(self):
length = self.length_entry.get()
iterations = self.iterations_entry.get()
try:
length = int(length)
iterations = int(iterations)
except ValueError:
self.error_message("Please enter a number")
return
try:
if length < 1 or length > 10:
raise ValueError("Please enter a number between 1 and 10")
if iterations < 1:
raise ValueError("Please enter a positive number of iterations")
rand_list = self.generate_random(iterations, length)
self.run_macro(rand_list)
except ValueError as e:
self.error_message(str(e))
def generate_random(self, iterations, length):
rand_list = []
if iterations > 100:
print("Warning: your selected number of iterations is greater than 100. This may lead to complications in search procedure.")
for x in range(iterations):
rand = ''
for i in range(length):
rand += random.choice(string.ascii_letters + string.digits)
rand_list.append(rand)
return rand_list
else:
for x in range(iterations):
rand = ''
for i in range(length):
rand += random.choice(string.ascii_letters + string.digits)
rand_list.append(rand)
return rand_list
def run_macro(self, rand_list):
self.is_running = True
pyautogui.click(2259, 117)
for i in range(1, len(rand_list)):
if not self.is_running:
break
time.sleep(1)
pyautogui.click(1695, 388)
for y in range(len(rand_list[i])):
pyautogui.press('backspace')
time.sleep(0.1)
pyautogui.typewrite(rand_list[i])
pyautogui.press('enter')
time.sleep(1.5)
pyautogui.click(2443, 117)
time.sleep(0.2)
pyautogui.click(1328,252)
time.sleep(0.1)
def stop_macro(self):
if self.is_running:
self.is_running = False
else:
self.is_running = True
self.run_macro(self.rand_list)
def error_message(self, message):
error_window = tk.Toplevel(self.master)
error_window.title("Error")
error_label = tk.Label(error_window, text=message)
error_label.pack(side="top")
error_button = tk.Button(error_window, text="OK", command=error_window.destroy)
error_button.pack(side="bottom")
root = tk.Tk()
root.title("Growtopia World Finder v0.1")
app = App(master=root)
app.mainloop()