-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnti-AFK.py
More file actions
67 lines (57 loc) · 1.8 KB
/
Copy pathAnti-AFK.py
File metadata and controls
67 lines (57 loc) · 1.8 KB
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
"""
A Simple Anti-AFK Script
author@NotCatal1n
Powered by SigmaTech.LLC
"""
import time
import itertools
import sys
try:
import keyboard
except Exception as e:
print("[relink_script] 需要安装依赖:keyboard。运行 `pip install -r requirements.txt` 然后以管理员权限运行脚本。")
raise
def _rgb_gradient(start, end, steps):
sr, sg, sb = start
er, eg, eb = end
for i in range(steps):
t = i / max(1, steps - 1)
r = int(sr + (er - sr) * t)
g = int(sg + (eg - sg) * t)
b = int(sb + (eb - sb) * t)
yield r, g, b
def gradient_text(text, start_color=(0,255,0), end_color=(0,255,255)):
chars = list(text)
colors = list(_rgb_gradient(start_color, end_color, len(chars)))
parts = []
for ch, (r, g, b) in zip(chars, colors):
parts.append(f"\x1b[38;2;{r};{g};{b}m{ch}")
parts.append("\x1b[0m")
return "".join(parts)
def main():
keys = ["w", "a", "s", "d"]
period = 5.0
press_duration = 1.0
remainder_sleep = max(0.0, period - press_duration)
print(gradient_text("[relink_script_api_calling] 小时候Sn的妈妈做机器学习脚本的时候挂机5分钟程序自动被结束了,因为你不可以挂机超过5分钟"))
print("Powered by SigmaStudio")
print("author@NotCatal1n")
print("Github: https://github.com/Fedal987/AntiAFK-Script")
print("[relink_script] 启动 main.py, 按 Ctrl+C 退出.")
try:
for key in itertools.cycle(keys):
print(f"PacketEvents: {key.upper()}")
keyboard.press(key)
time.sleep(press_duration)
keyboard.release(key)
time.sleep(remainder_sleep)
except KeyboardInterrupt:
print(f"[relink_script] main.py 已停止运行.(KeyboardInterrupt)")
try:
for k in keys:
keyboard.release(k)
except Exception:
pass
sys.exit(0)
if __name__ == "__main__":
main()