Skip to content

Commit

Permalink
added pause fiture, some bug fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
SunOner committed Dec 14, 2023
1 parent cf18593 commit 10e0898
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 18 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ Before you get started, make sure you have the following prerequisites installed
- I advise you to check the environment by running `checks.py`, it will let you know what and where to fix or re-install.
- To launch the aimbot after all installations, type ``python run.py`` or `py run.py` in cmd.

## Hot keys
- `Right mouse button` : Aiming at the target.
- `F2` : Exit.
- `F3` : Pause AIM.
> You can change the buttons in run.py
## Tested Environment
### The YOLOv8 Aimbot has been tested on the following environment:
<table>
Expand Down Expand Up @@ -111,11 +117,6 @@ The behavior of the aim bot can be configured via the [`config.ini`](https://git
<br></br>
- My .engine model was exported using specification version 8.6 (on an rtx 3080-TI graphics card). So if you were to run my .engine model on a gtx 1080 graphics card, the model would not start. You need to export it yourself. See what specification your graphics card [supports](https://ru.wikipedia.org/wiki/CUDA). So if your graphics card supports the 8.6 specification, then the model will start. The error may also occur due to the fact that I exported the model in a different version of TensorRT, it's better to just export the model yourself.

## Hot keys
- [`Right mouse button`](https://github.com/SunOner/yolov8_aimbot/blob/main/run.py#L28): Aiming at the target.
- [`F2`](https://github.com/SunOner/yolov8_aimbot/blob/main/run.py#L154): Exit.
> You can change the buttons in run.py
## Export .pt model to .engine
- Run in console:
```cmd
Expand Down
4 changes: 3 additions & 1 deletion checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ def run_checks():
print('mouse_smoothing', mouse_smoothing)
print('mouse_auto_shoot', mouse_auto_shoot)
print('mouse_auto_aim', mouse_auto_aim)
print('mouse_native', mouse_native, '\n')
print('mouse_native', mouse_native)
print('mouse_move_by_arduino', mouse_move_by_arduino)
print('mouse_shoot_by_arduino', mouse_shoot_by_arduino, '\n')

print('AI_model_path', AI_model_path)
print('AI_image_size', AI_image_size)
Expand Down
42 changes: 30 additions & 12 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,49 @@
import queue
import time
from logic.targets import *

from logic.screen import *
from logic.frame import get_new_frame, speed, draw_helpers
from logic.mouse import win32_raw_mouse_move
from logic.config_watcher import *
if mouse_move_by_arduino or mouse_shoot_by_arduino:
from logic.mouse import arduino


class work_queue(threading.Thread):
def __init__(self):
super(work_queue, self).__init__()
self.queue = queue.Queue()
self.daemon = True
self.queue.maxsize = AI_max_det
self.queue.maxsize = 100
self.start()

def run(self):
while True:
item = self.queue.get()
# https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
if win32api.GetAsyncKeyState(win32con.VK_RBUTTON) and mouse_auto_aim == False:
asyncio.run(win32_raw_mouse_move(x=item[0], y=item[1], target_x=item[2], target_y=item[3], target_w=item[4], target_h=item[5], distance=item[6]))
shooting_key = win32api.GetAsyncKeyState(win32con.VK_RBUTTON)

item = self.queue.get()

x, y, target_x, target_y, target_w, target_h, distance = item

# By key pressed
if shooting_key == -32768 and mouse_auto_aim == False:
asyncio.run(win32_raw_mouse_move(x=x, y=y, target_x=target_x, target_y=target_y, target_w=target_w, target_h=target_h, distance=distance))
if mouse_shoot_by_arduino:
arduino.press()
else:
if mouse_shoot_by_arduino and shooting_key == 0:
arduino.release()
# Auto shoot
if mouse_auto_shoot == True and mouse_auto_aim == False:
asyncio.run(win32_raw_mouse_move(x=None, y=None, target_x=item[2], target_y=item[3], target_w=item[4], target_h=item[5], distance=item[6]))
asyncio.run(win32_raw_mouse_move(x=None, y=None, target_x=target_x, target_y=target_y, target_w=target_w, target_h=target_h, distance=distance))

# Auto AIM
if mouse_auto_aim:
try:
asyncio.run(win32_raw_mouse_move(x=item[0], y=item[1], target_x=item[2], target_y=item[3], target_w=item[4], target_h=item[5], distance=item[6]))
asyncio.run(win32_raw_mouse_move(x=x, y=y, target_x=target_x, target_y=target_y, target_w=target_w, target_h=target_h, distance=distance))
except: pass

self.queue.task_done()

def append_queue(boxes, queue_worker):
shooting_queue = []
Expand Down Expand Up @@ -85,7 +100,7 @@ def init():
if '.engine' in AI_model_path:
print('Engine loaded')

print('Aimbot is started. Enjoy!\n[Right mouse button] - Aiming at the target\n[F2] - EXIT')
print('Aimbot is started. Enjoy!\n[Right mouse button] - Aiming at the target\n[F2] - EXIT\n[F3] - PAUSE AIM')

if show_window:
print('An open debug window can affect performance.')
Expand All @@ -105,6 +120,8 @@ def init():
while True:
frame = get_new_frame()

app_pause = win32api.GetKeyState(win32con.VK_F3)

result = model.predict(
source=frame,
stream=True,
Expand Down Expand Up @@ -137,7 +154,8 @@ def init():
annotated_frame = speed(annotated_frame, frame.speed['preprocess'], frame.speed['inference'], frame.speed['postprocess'])

if len(frame.boxes):
append_queue(frame.boxes, queue_worker)
if app_pause != 1:
append_queue(frame.boxes, queue_worker)

if show_window and show_boxes:
annotated_frame = draw_helpers(annotated_frame=annotated_frame, boxes=frame.boxes)
Expand All @@ -151,10 +169,10 @@ def init():
else:
cv2.putText(annotated_frame, 'FPS: {0}'.format(str(int(fps))), (10, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 255, 0), 1, cv2.LINE_AA)

if win32api.GetAsyncKeyState(win32con.VK_F2):
if win32api.GetAsyncKeyState(win32con.VK_F2) & 0xFF:
if show_window:
cv2.destroyWindow(debug_window_name)
quit(0)
break

if show_window:
try:
Expand Down

0 comments on commit 10e0898

Please sign in to comment.