-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
104 lines (79 loc) · 2.91 KB
/
main.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
from tkinter import messagebox
import pyautogui as pag
import time
import random
import keyboard
import os
def go_unl(bot_status):
time_delayed = 0.0
bot_status.config(text="Status: ON")
# Primary monitor size
screen_width, screen_high = pag.size()
while True:
time.sleep(3)
# Mouse move
pag.click()
x = random.randint(0, screen_width)
y = random.randint(0, screen_high)
pag.moveTo(x, y, 0.5)
# Keyboard move
pag.press(['w', 's', 'a', 'd', 'space'])
time_delayed += 3
def go(working_time, bot_status):
time_delayed = 0.0
bot_status.config(text="Status: ON")
# Primary monitor size
screen_width, screen_high = pag.size()
while time_delayed <= working_time:
time.sleep(3)
# Mouse move
pag.click()
x = random.randint(0, screen_width)
y = random.randint(0, screen_high)
pag.moveTo(x, y, 0.5)
# Keyboard move
pag.press(['w', 's', 'a', 'd', 'space'])
time_delayed += 3
bot_status.config(text="Status: BOT HAS FINISHED HIS WORK")
def record(save_directory, filename, bot_status, button_start):
try:
bot_status.config(text="Status: ON")
recording = keyboard.record(until='f10')
path = save_directory + f"\{filename}.txt"
f = open(path, 'w')
for rec in recording:
if rec == recording[-1]:
f.write(f'{str(rec)}')
else:
f.write(f'{str(rec)},')
f.close()
button_start['state'] = 'normal'
bot_status.config(text="Status: OFF")
messagebox.showinfo('Done', 'Record saved successfully',)
except:
button_start['state'] = 'normal'
bot_status.config(text="Status: OFF")
messagebox.showerror('Error', 'Something went wrong. Try again.')
def play(file, loop, speed, bot_status, button_start):
try:
bot_status.config(text="Status: ON")
list_keyboard_event = []
f = open(file, 'r')
recording = f.read()
record_list = recording.split(sep=',')
for rec in record_list:
sliced = slice(rec.find('(') + 2, rec.find(')'), 1)
list_keyboard_event.append(keyboard.KeyboardEvent(rec[sliced].strip(), rec[rec.find('(')+1],))
if loop:
while True:
keyboard.play(list_keyboard_event, speed_factor=speed)
time.sleep(1)
else:
keyboard.play(list_keyboard_event, speed_factor=speed)
button_start['state'] = 'normal'
bot_status.config(text="Status: OFF")
messagebox.showinfo('Done', 'Action has ended', )
except:
button_start['state'] = 'normal'
bot_status.config(text="Status: OFF")
messagebox.showerror('Error', 'Something went wrong. Try again.')