-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAntiAFK-GUI.py
122 lines (103 loc) · 4.39 KB
/
AntiAFK-GUI.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
112
113
114
115
116
117
118
119
120
121
122
### IMPORTS ###
import PySimpleGUI as sg
import sys
import subprocess
import os
import requests
from time import sleep as sl
from PySimpleGUI.PySimpleGUI import BUTTON_TYPE_READ_FORM, Window
from pyautogui import press, typewrite, hotkey
from time import sleep
from random import randint, randbytes
### DEFINITIONS ###
secs = 0
mins = 0
hours = 0
minconst = 1
secconst = 0
def MESSAGE(IGN, MSG):
press('enter')
typewrite("/msg " + str(IGN) + " I have been afk for " + str(hours) + " hours, and " + str(mins) + " minutes, and " + str(secs) + " seconds.")
press('enter')
press('enter')
if str(MSG) == str("") or str(MSG) == 'Leave blank for default.':
typewrite('> I have been AFK for ' + str(hours) + ' hours and ' + str(mins) + ' minutes, and ' + str(secs) + ' seconds. ' + str(randbytes(15)))
else:
typewrite("> " + str(MSG) + " " + str(randbytes(15)))
press('enter')
print('Sent a message in chat.')
DefIGN = "e.g. PopBob"
### LAYOUTS ###
sg.change_look_and_feel('DarkGray')
layoutInputs = [
[sg.Text('Please enter your username and message to send in chat. ')],
[sg.Text('This is my first real project, so please give criticism on')],
[sg.Text('my GitHub: github.com/Tytanium13/TysAntiAFK')],
[sg.Text(' ')],
[sg.Text('IGN:', size=(15, 1)), sg.InputText(DefIGN,tooltip='The username of the player to send a /MSG to.')],
[sg.Text('Chat message*:', size =(15, 1)), sg.InputText("Leave blank for default.",tooltip='Message to send in chat (Leave blank for default).')],
[sg.Submit('Run', tooltip='Run the script.'), sg.Cancel('Quit', tooltip='Kills the script and closes the window.')],
]
layoutInputError = [
[sg.Text('Please enter your username and message to send in chat. ')],
[sg.Text('This is my first real project, so please give criticism on')],
[sg.Text('my GitHub: github.com/Tytanium13/TysAntiAFK')],
[sg.Text('Error: Please enter a valid username! ')],
[sg.Text('IGN:', size=(15, 1)), sg.InputText(DefIGN,tooltip='The username of the player to send a /MSG to.')],
[sg.Text('Chat message*:', size =(15, 1)), sg.InputText("Leave blank for default.",tooltip='Message to send in chat (Leave blank for default).')],
[sg.Submit('Run', tooltip='Run the script.'), sg.Cancel('Quit', tooltip='Kills the script and closes the window.')],
]
layoutOutputs = [
[
sg.Button("Quit", tooltip='Kills the script and closes the window.'),
],
]
### CREATING THE WINDOW AND FUNCTIONS ###
window = sg.Window("Ty's AntiAFK", layoutInputs, size=(500,210))
x = 0
while True:
if x == 0:
event, values = window.read()
if event == "Run":
event, values = window.read()
IGN = values[0]
MSG = values[1]
window.close()
window = sg.Window("RUNNING | Ty's AntiAFK", layoutOutputs, size=(200,100))
print('IGN: ' + str(IGN))
print('Chat MSG: ' + str(MSG))
x = 1
if x == 1:
# Basic MSG.
secs += 1
if secs > 59:
secs = 0
mins += 1
if mins > 59:
mins = 0
hours += 1
# Printing in the terminal
if hours < 10 and mins < 10 and secs < 10:
print('AFK for 0' + str(hours) + ":0" + str(mins) + ".0" + str(secs))
elif hours >= 10 and mins < 10 and secs < 10:
print('AFK for ' + str(hours) + ":0" + str(mins) + ".0" + str(secs))
elif hours >= 10 and mins >= 10 and secs < 10:
print('AFK for ' + str(hours) + ":" + str(mins) + ".0" + str(secs))
elif hours >= 10 and mins >= 10 and secs >= 10:
print('AFK for ' + str(hours) + ":" + str(mins) + "." + str(secs))
elif hours < 10 and mins >= 10 and secs >= 10:
print('AFK for 0' + str(hours) + ":" + str(mins) + "." + str(secs))
elif hours < 10 and mins >= 10 and secs < 10:
print('AFK for 0' + str(hours) + ":" + str(mins) + ".0" + str(secs))
elif hours < 10 and mins < 10 and secs >= 10:
print('AFK for 0' + str(hours) + ":0" + str(mins) + "." + str(secs))
# Sending the messages
sleep(1)
if mins == minconst + 5 and secs == secconst:
MESSAGE(IGN, MSG)
minconst = mins
secconst = randint(0,59)
secs += 1
if event == "Quit" or event == sg.WIN_CLOSED:
window.close()
exit(0)