This repository was archived by the owner on Oct 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.py
139 lines (102 loc) · 3.25 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Valorant (any game really) trigger bot
# Made with ♥ by b0kch01
import colorama
from termcolor import cprint, colored
from pyfiglet import Figlet
from pynput.mouse import Controller, Button
from pynput import mouse
import numpy as np
import d3dshot
import time
import keyboard
import win32gui
import win32api
import os
import ctypes
# Disable quick-edit mode (pauses bot)
kernel32 = ctypes.windll.kernel32
kernel32.SetConsoleMode(kernel32.GetStdHandle(-10), 128)
# Fix legacy console color
colorama.init()
# CONSTANTS
KEYBIND = "alt" # Default keybind
BOX_LENGTH = 4 # Screen capture size
SCREEN_X = win32api.GetSystemMetrics(0) # Auto-fetched (doesn't always work)
SCREEN_Y = win32api.GetSystemMetrics(1)
# Calculating box coorinates
X1 = int(SCREEN_X/2 - BOX_LENGTH/2)
Y1 = int(SCREEN_Y/2 - BOX_LENGTH/2)
X2 = int(X1 + BOX_LENGTH)
Y2 = int(Y1 + BOX_LENGTH)
REGION = (X1, Y1, X2, Y2)
cprint("Setting up...")
cprint(" - [¤] Windows", "green")
cprint(f" - [¤] {SCREEN_X}x{SCREEN_Y}", "green")
if ctypes.windll.shell32.IsUserAnAdmin() == 0:
cprint(" - [x] Please run as administrator", "red")
exit(0)
cprint(f" - [¤] {SCREEN_X}x{SCREEN_Y}", "green")
time.sleep(0.5)
# Disable click delay (100ms)
win32gui.GetDoubleClickTime = lambda: 0
# Instantiate mouse controller
mouse = Controller()
# Instantiate screen capture (numpy is the fastest)
d = d3dshot.create(capture_output="numpy")
# Grabs center screen as an average pixel value
def rgb_pixel():
return np.average(d.screenshot(region=REGION))
# Given start time, returns time elapsed in ms
def time_elapsed(start_time):
return str(int((time.time() - start_time)*1000)) + "ms"
# User Interface
f = Figlet(font="ogre")
CACHED_TITLESCREEN = f"""
{ f.renderText("Valorant Cheat")[:-3] }
{ colored(" Created with ♥ by b0kch01! ", "grey", "on_white") }
{ colored(" USE AT YOUR OWN RISK ", "grey", "on_yellow") }
Enjoy! :)
"""
# Clears console
def clear():
os.system("cls")
# Prints titlescreen
def titlescreen():
clear()
print(CACHED_TITLESCREEN)
# MAIN SCRIPT
try:
titlescreen()
if input("Set custom keybind? (yes/no): ")[:1] in "yY":
titlescreen()
print(f"Current keybind: [{colored(KEYBIND, 'green')}]")
print("\nPress [ESC] to continue")
new_key = KEYBIND
while True:
new_key = keyboard.read_key()
if new_key == "esc":
break
elif new_key != KEYBIND:
KEYBIND = new_key
titlescreen()
print(f"Current keybind: [{colored(KEYBIND, 'green')}]")
print("\nPress [ESC] to continue")
titlescreen()
print(f"Current keybind: [{colored(KEYBIND, 'green')}]")
cprint("\nReady to frag.", "green")
current_pixel = rgb_pixel()
while True:
if keyboard.is_pressed(KEYBIND):
timeS = time.time()
new_pixel = rgb_pixel()
if abs(current_pixel - new_pixel) > 5:
mouse.click(Button.left)
print("[¤] Clicked within " + time_elapsed(timeS))
current_pixel = new_pixel
else:
current_pixel = rgb_pixel()
time.sleep(0.05)
except KeyboardInterrupt:
pass
cprint("\n~ Program exited ;-;", "grey", "on_red")
time.sleep(1)