-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
70 lines (55 loc) · 1.94 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
import random
import pyautogui
import time
keys = ["w", "a", "s", "d"]
class term_color:
FAIL = '\033[91m'
ENDC = '\033[0m'
def mode_selection():
available_selection = [1, 2]
while True:
try:
selection = int(input(
"Select your anti-AFK mode\n" +
"[1] Social (Teams,Skype,Discord) This mode moves the mouse every interval you specified. \n" +
"[2] Games (Minecraft,CSGO....) This mode moves the mouse and presses movement keys (WASD) every interval you specified.\n"
">>> "))
if available_selection.__contains__(selection):
return selection
else:
raise ValueError
except ValueError:
print(f"{term_color.FAIL}Chose a valid number from the list{term_color.ENDC}")
def seconds_interval():
while True:
try:
second_selection = int(input("Select every how many seconds it will repeat >>> "))
if isinstance(second_selection, int):
return second_selection
else:
raise ValueError
except ValueError:
print(f"{term_color.FAIL}Value must be a number{term_color.ENDC}")
def move_mouse():
current_mouse_x, current_mouse_y = pyautogui.position()
pyautogui.moveTo(current_mouse_x - 1, current_mouse_y - 1)
def main():
try:
mode = mode_selection()
seconds_to_repeat = seconds_interval()
while True:
if mode == 1:
move_mouse()
elif mode == 2:
move_mouse()
rand = random.randint(0, len(keys) - 1)
press_and_depress_with_delay(keys[rand], 0.5)
time.sleep(seconds_to_repeat)
except KeyboardInterrupt:
pass
def press_and_depress_with_delay(key, sleep):
pyautogui.keyDown(key)
time.sleep(sleep)
pyautogui.keyUp(key)
if __name__ == "__main__":
main()