import os
import sys
import time
import json
import ctypes
import threading
import numpy as np
import cv2
import onnxruntime as ort
from mss import mss
from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout,
QLabel, QPushButton, QSlider, QComboBox, QCheckBox,
QFileDialog, QGroupBox, QSpinBox, QDoubleSpinBox, QTabWidget,
QMessageBox, QProgressBar)
from PyQt5.QtCore import Qt, QTimer, QSettings, QPoint, QThread, pyqtSignal
from PyQt5.QtGui import QImage, QPixmap, QPainter, QPen, QColor, QFont
from pynput import keyboard, mouse
# ==============================================
# 常量定义
# ==============================================
DEFAULT_CONF_THRESHOLD = 70 # 默认置信度阈值(百分比)
DEFAULT_CIRCLE_RADIUS = 300 # 默认圆形范围(像素)
DEFAULT_MOVE_SPEED = 10 # 默认移动速度(百分比)
DEFAULT_SHOW_CONTOURS = True
DEFAULT_SHOW_CONF = True
# ==============================================
# 模型类 (AIModel)
# ==============================================
class AIModel:
def __init__(self, model_path=None):
self.model = None
self.input_name = None
self.output_name = None
self.model_loaded = False
if model_path:
self.load_model(model_path)
def load_model(self, model_path):
try:
# 尝试使用GPU加速,如果不可用则使用CPU
providers = ['CUDAExecutionProvider', 'CPUExecutionProvider']
self.model = ort.InferenceSession(model_path, providers=providers)
self.input_name = self.model.get_inputs()[0].name
self.output_name = self.model.get_outputs()[0].name
self.model_loaded = True
return True
except Exception as e:
print(f"[错误] 模型加载失败: {e}")
self.model_loaded = False
return False
def predict(self, image, conf_threshold=0.5):
if not self.model_loaded:
return [], 0
try:
# 记录推理开始时间
start_time = time.perf_counter()
# 预处理图像
input_tensor = self.preprocess(image)
# 执行推理
outputs = self.model.run([self.output_name], {self.input_name: input_tensor})[0]
# 后处理结果
detections = self.postprocess(outputs, conf_threshold)
# 计算推理时间(毫秒)
inference_time = (time.perf_counter() - start_time) * 1000
return detections, inference_time
except Exception as e:
print(f"[错误] 模型推理失败: {e}")
return [], 0
def preprocess(self, image):
# 调整图像大小为模型输入尺寸
image = cv2.resize(image, (640, 640))
# 转换通道顺序 (HWC to CHW)
image = image.transpose(2, 0, 1)
# 添加批次维度并归一化
image = np.expand_dims(image, axis=0).astype(np.float32) / 255.0
return image
def postprocess(self, outputs, conf_threshold):
# 假设输出格式为 [batch, num_detections, 6] (x1, y1, x2, y2, conf, class_id)
detections = []
for detection in outputs[0]:
confidence = detection[4]
if confidence > conf_threshold:
x1, y1, x2, y2 = detection[:4]
# 确保坐标值有效
if x1 < x2 and y1 < y2:
detections.append({
'box': [x1, y1, x2, y2],
'conf': confidence * 100, # 转换为百分比
'class_id': int(detection[5]),
'center': [(x1 + x2) / 2, (y1 + y2) / 2]
})
return detections
# ==============================================
# 屏幕捕获类 (ScreenCapture)
# ==============================================
class ScreenCapture:
def __init__(self):
# 使用线程本地存储解决多线程问题
self.thread_local = threading.local()
self.monitor = self.get_primary_monitor()
self.last_capture_time = 0
self.capture_interval = 0.05 # 20 FPS
def get_primary_monitor(self):
"""安全获取主显示器信息"""
try:
with mss() as temp_sct:
for monitor in temp_sct.monitors:
if monitor["left"] == 0 and monitor["top"] == 0:
return monitor
return temp_sct.monitors[0]
except Exception as e:
print(f"[错误] 获取显示器信息失败: {e}")
# 返回默认值
return {"top": 0, "left": 0, "width": 1920, "height": 1080}
def get_sct_instance(self):
"""获取当前线程的mss实例"""
if not hasattr(self.thread_local, 'sct') or self.thread_local.sct is None:
try:
self.thread_local.sct = mss()
except Exception as e:
print(f"[错误] 创建mss实例失败: {e}")
return None
return self.thread_local.sct
def capture(self):
current_time = time.time()
# 控制捕获频率
if current_time - self.last_capture_time < self.capture_interval:
return None
try:
sct = self.get_sct_instance()
if sct is None:
return None
# 捕获屏幕
img = np.array(sct.grab(self.monitor))
# 转换颜色空间 (BGRA to BGR)
self.last_capture_time = current_time
return cv2.cvtColor(img, cv2.COLOR_BGRA2BGR)
except Exception as e:
print(f"[错误] 屏幕捕获失败: {e}")
# 重置当前线程的sct实例
if hasattr(self.thread_local, 'sct'):
self.thread_local.sct = None
return None
# ==============================================
# 瞄准系统主类 (AimbotSystem)
# ==============================================
class AimbotSystem(QThread):
# 信号用于更新UI
status_update = pyqtSignal(float, float, int, bool)
def __init__(self):
super().__init__()
self.capture = ScreenCapture()
self.model = AIModel()
self.active = False
self.conf_threshold = DEFAULT_CONF_THRESHOLD
self.circle_radius = DEFAULT_CIRCLE_RADIUS
self.move_speed = DEFAULT_MOVE_SPEED
self.show_contours = DEFAULT_SHOW_CONTOURS
self.show_conf = DEFAULT_SHOW_CONF
self.targets = []
self.fps = 0
self.inference_time = 0
self.last_time = time.time()
self.key_bind = None
self.key_listener = None
self.mouse_listener = None
self.bound_key = None
self.bound_button = None
self.key_state = False
self.running = True
self.lock = threading.Lock()
# 初始化按键监听器
self.start_listeners()
def start_listeners(self):
# 停止现有的监听器
self.stop_listeners()
# 启动新的监听器
if self.bound_key:
self.key_listener = keyboard.Listener(
on_press=self.on_key_press,
on_release=self.on_key_release
)
self.key_listener.start()
elif self.bound_button:
self.mouse_listener = mouse.Listener(
on_click=self.on_mouse_click
)
self.mouse_listener.start()
def stop_listeners(self):
if self.key_listener:
self.key_listener.stop()
self.key_listener = None
if self.mouse_listener:
self.mouse_listener.stop()
self.mouse_listener = None
def on_key_press(self, key):
try:
if key == self.bound_key:
self.active = True
self.key_state = True
except AttributeError:
pass
def on_key_release(self, key):
try:
if key == self.bound_key:
self.active = False
self.key_state = False
except AttributeError:
pass
def on_mouse_click(self, x, y, button, pressed):
if button == self.bound_button:
self.active = pressed
self.key_state = pressed
def update_settings(self, conf_threshold, circle_radius, move_speed,
show_contours, show_conf, key_bind=None, mouse_bind=None):
with self.lock:
self.conf_threshold = conf_threshold
self.circle_radius = circle_radius
self.move_speed = move_speed
self.show_contours = show_contours
self.show_conf = show_conf
# 更新按键绑定
if key_bind:
self.key_bind = key_bind
self.bound_key = key_bind
self.bound_button = None
elif mouse_bind:
self.key_bind = mouse_bind
self.bound_button = mouse_bind
self.bound_key = None
# 重新启动监听器
self.start_listeners()
def process_frame(self):
try:
start_time = time.time()
# 捕获屏幕
frame = self.capture.capture()
if frame is None:
time.sleep(0.01)
return
# 确保捕获到有效帧
if frame.size == 0:
print("[警告] 捕获到空帧")
return
screen_center = (frame.shape[1] // 2, frame.shape[0] // 2)
# 执行推理
targets, inference_time = self.model.predict(frame, self.conf_threshold / 100.0)
# 筛选圆形区域内的目标
valid_targets = []
for target in targets:
center = target['center']
distance = np.sqrt((center[0] - screen_center[0])**2 +
(center[1] - screen_center[1])**2)
if distance <= self.circle_radius:
valid_targets.append(target)
# 找到最近的目标
closest_target = None
min_distance = float('inf')
for target in valid_targets:
center = target['center']
distance = np.sqrt((center[0] - screen_center[0])**2 +
(center[1] - screen_center[1])**2)
if distance < min_distance:
min_distance = distance
closest_target = target
# 移动鼠标
if self.active and closest_target:
target_x, target_y = closest_target['center']
rel_x = screen_center[0] - target_x
rel_y = screen_center[1] - target_y
# 应用速度控制
move_x = rel_x * (self.move_speed / 100)
move_y = rel_y * (self.move_speed / 100)
move_mouse(move_x, move_y)
# 计算FPS
end_time = time.time()
fps = 1 / (end_time - start_time) if end_time > start_time else 0
# 更新状态
self.status_update.emit(fps, inference_time, len(targets), self.key_state)
self.targets = targets # 更新目标列表用于覆盖层绘制
def run(self):
while self.running:
try:
self.process_frame()
time.sleep(0.001) # 避免过度占用CPU
except Exception as e:
print(f"[错误] 处理帧时出错: {e}")
def stop(self):
self.running = False
self.stop_listeners()
# ==============================================
# 覆盖窗口绘制类 (OverlayWindow)
# ==============================================
class OverlayWindow(QWidget):
def __init__(self, aimbot):
super().__init__()
self.aimbot = aimbot
self.setWindowTitle("Aimbot Overlay")
self.setAttribute(Qt.WA_TranslucentBackground)
self.setAttribute(Qt.WA_TransparentForMouseEvents)
self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Tool)
# 获取屏幕尺寸
screen = QApplication.primaryScreen().geometry()
self.setGeometry(0, 0, screen.width(), screen.height())
self.targets = []
self.timer = QTimer()
self.timer.timeout.connect(self.update_overlay)
self.timer.start(50) # 20 FPS
def update_overlay(self):
# 安全获取目标列表
self.targets = self.aimbot.targets.copy()
self.update()
def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.Antialiasing)
# 绘制圆形区域
center = self.rect().center()
painter.setPen(QPen(QColor(0, 255, 0, 150), 2))
painter.drawEllipse(center, self.aimbot.circle_radius, self.aimbot.circle_radius)
# 绘制目标和信息
for target in self.targets:
x1, y1, x2, y2 = target['box']
center_x, center_y = target['center']
# 绘制目标框
if self.aimbot.show_contours:
painter.setPen(QPen(QColor(255, 0, 0, 200), 2))
painter.drawRect(int(x1), int(y1), int(x2 - x1), int(y2 - y1))
# 绘制中心点
painter.setPen(QPen(QColor(0, 0, 255, 200), 4))
painter.drawPoint(int(center_x), int(center_y))
# 绘制置信度 (百分比形式)
if self.aimbot.show_conf:
painter.setPen(QColor(255, 255, 255))
painter.setFont(QFont('Arial', 10))
painter.drawText(
int(x1), int(y1) - 5,
f"{target['conf']:.1f}%"
)
# ==============================================
# 控制面板类 (ControlPanel)
# ==============================================
class ControlPanel(QMainWindow):
def __init__(self, aimbot):
super().__init__()
self.aimbot = aimbot
self.setWindowTitle("AI瞄准控制系统")
self.setGeometry(100, 100, 500, 600)
# 初始化设置对象
self.settings = QSettings("AimbotConfig.ini", QSettings.IniFormat)
# 主布局
main_widget = QWidget()
self.setCentralWidget(main_widget)
main_layout = QVBoxLayout(main_widget)
# 创建分页式菜单
self.tabs = QTabWidget()
# 模型设置分页
model_tab = self.create_model_tab()
# 瞄准设置分页
aim_tab = self.create_aim_tab()
# 显示设置分页
display_tab = self.create_display_tab()
# 状态信息分页
status_tab = self.create_status_tab()
# 添加分页
self.tabs.addTab(model_tab, "模型设置")
self.tabs.addTab(aim_tab, "瞄准设置")
self.tabs.addTab(display_tab, "显示设置")
self.tabs.addTab(status_tab, "状态信息")
main_layout.addWidget(self.tabs)
# 控制按钮
btn_layout = QHBoxLayout()
self.apply_btn = QPushButton("应用设置")
self.apply_btn.clicked.connect(self.apply_settings)
btn_layout.addWidget(self.apply_btn)
self.exit_btn = QPushButton("退出程序")
self.exit_btn.clicked.connect(self.close_app)
btn_layout.addWidget(self.exit_btn)
main_layout.addLayout(btn_layout)
# 连接信号
self.aimbot.status_update.connect(self.update_status)
# 加载设置
self.load_settings()
# 置顶窗口
self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)
# 按键绑定状态
self.binding = False
self.binding_type = None
self.bound_key = None
self.bound_button = None
def create_model_tab(self):
tab = QWidget()
layout = QVBoxLayout(tab)
group = QGroupBox("模型设置")
group_layout = QVBoxLayout()
self.model_path_label = QLabel("未选择模型")
group_layout.addWidget(self.model_path_label)
btn_layout = QHBoxLayout()
self.select_btn = QPushButton("选择模型")
self.select_btn.clicked.connect(self.select_model)
btn_layout.addWidget(self.select_btn)
self.load_btn = QPushButton("加载模型")
self.load_btn.clicked.connect(self.load_model)
btn_layout.addWidget(self.load_btn)
group_layout.addLayout(btn_layout)
# 添加模型加载进度条
self.progress_bar = QProgressBar()
self.progress_bar.setRange(0, 100)
self.progress_bar.setVisible(False)
group_layout.addWidget(self.progress_bar)
group.setLayout(group_layout)
layout.addWidget(group)
layout.addStretch()
return tab
def create_aim_tab(self):
tab = QWidget()
layout = QVBoxLayout(tab)
group = QGroupBox("瞄准设置")
group_layout = QVBoxLayout()
# 置信度阈值滑块 (百分比)
conf_layout = QHBoxLayout()
conf_layout.addWidget(QLabel("置信度阈值(%):"))
self.conf_value_label = QLabel(f"{DEFAULT_CONF_THRESHOLD}%")
conf_layout.addWidget(self.conf_value_label)
group_layout.addLayout(conf_layout)
self.conf_slider = QSlider(Qt.Horizontal)
self.conf_slider.setRange(0, 100)
self.conf_slider.setValue(DEFAULT_CONF_THRESHOLD)
self.conf_slider.valueChanged.connect(
lambda v: self.conf_value_label.setText(f"{v}%")
)
group_layout.addWidget(self.conf_slider)
# 圆形范围滑块
circle_layout = QHBoxLayout()
circle_layout.addWidget(QLabel("圆形范围:"))
self.circle_value_label = QLabel(f"{DEFAULT_CIRCLE_RADIUS}px")
circle_layout.addWidget(self.circle_value_label)
group_layout.addLayout(circle_layout)
# 修复拼写错误
self.circle_slider = QSlider(Qt.Horizontal)
self.circle_slider.setRange(50, 800)
self.circle_slider.setValue(DEFAULT_CIRCLE_RADIUS)
self.circle_slider.valueChanged.connect(
lambda v: self.circle_value_label.setText(f"{v}px")
)
group_layout.addWidget(self.circle_slider)
# 移动速度滑块
speed_layout = QHBoxLayout()
speed_layout.addWidget(QLabel("移动速度:"))
self.speed_value_label = QLabel(f"{DEFAULT_MOVE_SPEED}%")
speed_layout.addWidget(self.speed_value_label)
group_layout.addLayout(speed_layout)
self.speed_slider = QSlider(Qt.Horizontal)
self.speed_slider.setRange(1, 100)
self.speed_slider.setValue(DEFAULT_MOVE_SPEED)
self.speed_slider.valueChanged.connect(
lambda v: self.speed_value_label.setText(f"{v}%")
)
group_layout.addWidget(self.speed_slider)
# 按键绑定
key_layout = QHBoxLayout()
key_layout.addWidget(QLabel("瞄准按键:"))
self.key_bind_btn = QPushButton("绑定键盘按键")
self.key_bind_btn.clicked.connect(lambda: self.bind_key("keyboard"))
key_layout.addWidget(self.key_bind_btn)
self.mouse_bind_btn = QPushButton("绑定鼠标按键")
self.mouse_bind_btn.clicked.connect(lambda: self.bind_key("mouse"))
key_layout.addWidget(self.mouse_bind_btn)
group_layout.addLayout(key_layout)
# 当前绑定显示
bind_display_layout = QHBoxLayout()
bind_display_layout.addWidget(QLabel("当前绑定:"))
self.bind_label = QLabel("未绑定")
bind_display_layout.addWidget(self.bind_label)
group_layout.addLayout(bind_display_layout)
group.setLayout(group_layout)
layout.addWidget(group)
layout.addStretch()
return tab
def create_display_tab(self):
tab = QWidget()
layout = QVBoxLayout(tab)
group = QGroupBox("显示设置")
group_layout = QVBoxLayout()
self.contour_check = QCheckBox("显示目标轮廓")
self.contour_check.setChecked(DEFAULT_SHOW_CONTOURS)
group_layout.addWidget(self.contour_check)
self.conf_check = QCheckBox("显示置信度")
self.conf_check.setChecked(DEFAULT_SHOW_CONF)
group_layout.addWidget(self.conf_check)
group.setLayout(group_layout)
layout.addWidget(group)
layout.addStretch()
return tab
def create_status_tab(self):
tab = QWidget()
layout = QVBoxLayout(tab)
group = QGroupBox("状态信息")
group_layout = QVBoxLayout()
self.fps_label = QLabel("FPS: 0")
group_layout.addWidget(self.fps_label)
self.inference_label = QLabel("检测速度: 0 ms")
group_layout.addWidget(self.inference_label)
self.targets_label = QLabel("检测目标: 0")
group_layout.addWidget(self.targets_label)
self.bind_state_label = QLabel("绑定状态: 未激活")
group_layout.addWidget(self.bind_state_label)
# 添加系统信息
sys_info_layout = QHBoxLayout()
sys_info_layout.addWidget(QLabel("CPU使用率:"))
self.cpu_label = QLabel("0%")
sys_info_layout.addWidget(self.cpu_label)
group_layout.addLayout(sys_info_layout)
group.setLayout(group_layout)
layout.addWidget(group)
layout.addStretch()
return tab
def select_model(self):
file_path, _ = QFileDialog.getOpenFileName(
self, "选择ONNX模型", "", "ONNX文件 (*.onnx)"
)
if file_path:
self.model_path = file_path
self.model_path_label.setText(os.path.basename(file_path))
def load_model(self):
if hasattr(self, 'model_path'):
# 显示进度条
self.progress_bar.setVisible(True)
self.progress_bar.setValue(0)
# 在后台线程中加载模型
def load_in_background():
try:
# 模拟加载过程
for i in range(1, 101):
time.sleep(0.02)
self.progress_bar.setValue(i)
success = self.aimbot.model.load_model(self.model_path)
if success:
self.model_path_label.setText(f"已加载: {os.path.basename(self.model_path)}")
else:
QMessageBox.warning(self, "加载失败", "模型加载失败,请检查文件格式")
except Exception as e:
print(f"模型加载错误: {e}")
QMessageBox.critical(self, "错误", f"加载模型时出错: {e}")
finally:
self.progress_bar.setVisible(False)
# 启动后台线程
threading.Thread(target=load_in_background, daemon=True).start()
def bind_key(self, bind_type):
self.binding = True
self.binding_type = bind_type
# 提示用户
QMessageBox.information(
self, "按键绑定",
"请按下要绑定的按键 (按ESC取消绑定)\n\n"
"按键将在按下时激活瞄准,松开时停止瞄准",
QMessageBox.Ok
)
# 启动全局监听器
if bind_type == "keyboard":
self.key_listener = keyboard.Listener(
on_press=self.on_bind_key_press,
on_release=self.on_bind_key_release
)
self.key_listener.start()
else:
self.mouse_listener = mouse.Listener(
on_click=self.on_bind_mouse_click
)
self.mouse_listener.start()
def on_bind_key_press(self, key):
if key == keyboard.Key.esc:
self.cancel_binding()
return
# 记录按下的按键
self.bound_key = key
self.bind_label.setText(f"键盘按键: {key}")
self.cancel_binding()
def on_bind_key_release(self, key):
pass
def on_bind_mouse_click(self, x, y, button, pressed):
if pressed:
# 记录按下的鼠标按键
self.bound_button = button
self.bind_label.setText(f"鼠标按键: {button.name}")
self.cancel_binding()
def cancel_binding(self):
self.binding = False
# 停止监听器
if hasattr(self, 'key_listener') and self.key_listener:
self.key_listener.stop()
if hasattr(self, 'mouse_listener') and self.mouse_listener:
self.mouse_listener.stop()
def apply_settings(self):
conf_threshold = self.conf_slider.value()
circle_radius = self.circle_slider.value()
move_speed = self.speed_slider.value()
show_contours = self.contour_check.isChecked()
show_conf = self.conf_check.isChecked()
self.aimbot.update_settings(
conf_threshold, circle_radius, move_speed,
show_contours, show_conf, self.bound_key, self.bound_button
)
# 保存设置
self.save_settings()
QMessageBox.information(self, "设置已应用", "所有设置已成功应用!")
def update_status(self, fps, inference_time, targets_count, key_state):
self.fps_label.setText(f"FPS: {fps:.1f}")
self.inference_label.setText(f"检测速度: {inference_time:.1f} ms")
self.targets_label.setText(f"检测目标: {targets_count}")
if key_state:
self.bind_state_label.setText("绑定状态: 激活中")
else:
self.bind_state_label.setText("绑定状态: 未激活")
def save_settings(self):
try:
self.settings.setValue("conf_threshold", self.aimbot.conf_threshold)
self.settings.setValue("circle_radius", self.aimbot.circle_radius)
self.settings.setValue("move_speed", self.aimbot.move_speed)
self.settings.setValue("show_contours", self.aimbot.show_contours)
self.settings.setValue("show_conf", self.aimbot.show_conf)
# 保存绑定按键
if self.bound_key:
self.settings.setValue("bound_key", str(self.bound_key))
if self.bound_button:
self.settings.setValue("bound_button", self.bound_button.name)
self.settings.setValue("geometry", self.saveGeometry())
except Exception as e:
print(f"保存设置时出错: {e}")
QMessageBox.warning(self, "保存错误", f"保存设置时出错: {e}")
def load_settings(self):
try:
# 加载基本设置
self.aimbot.conf_threshold = self.settings.value("conf_threshold", DEFAULT_CONF_THRESHOLD, int)
self.aimbot.circle_radius = self.settings.value("circle_radius", DEFAULT_CIRCLE_RADIUS, int)
self.aimbot.move_speed = self.settings.value("move_speed", DEFAULT_MOVE_SPEED, int)
self.aimbot.show_contours = self.settings.value("show_contours", DEFAULT_SHOW_CONTOURS, bool)
self.aimbot.show_conf = self.settings.value("show_conf", DEFAULT_SHOW_CONF, bool)
# 恢复滑块位置
self.conf_slider.setValue(self.aimbot.conf_threshold)
self.circle_slider.setValue(self.aimbot.circle_radius)
self.speed_slider.setValue(self.aimbot.move_speed)
# 更新标签显示
self.conf_value_label.setText(f"{self.aimbot.conf_threshold}%")
self.circle_value_label.setText(f"{self.aimbot.circle_radius}px")
self.speed_value_label.setText(f"{self.aimbot.move_speed}%")
# 恢复复选框状态
self.contour_check.setChecked(self.aimbot.show_contours)
self.conf_check.setChecked(self.aimbot.show_conf)
# 加载绑定按键
bound_key_str = self.settings.value("bound_key", "")
if bound_key_str:
try:
# 解析按键字符串 (例如 "Key.ctrl" 或 "Key.f1")
key_name = bound_key_str.split('.')[1]
self.bound_key = getattr(keyboard.Key, key_name)
self.bind_label.setText(f"键盘按键: {key_name}")
except Exception as e:
print(f"加载键盘绑定失败: {e}")
self.bound_key = None
bound_button = self.settings.value("bound_button", "")
if bound_button:
try:
# 解析鼠标按键 (例如 "left" 或 "right")
self.bound_button = getattr(mouse.Button, bound_button)
self.bind_label.setText(f"鼠标按键: {bound_button}")
except Exception as e:
print(f"加载鼠标绑定失败: {e}")
self.bound_button = None
# 更新瞄准系统的绑定
self.aimbot.update_settings(
self.aimbot.conf_threshold,
self.aimbot.circle_radius,
self.aimbot.move_speed,
self.aimbot.show_contours,
self.aimbot.show_conf,
key_bind=self.bound_key,
mouse_bind=self.bound_button
)
# 恢复窗口位置
if self.settings.contains("geometry"):
self.restoreGeometry(self.settings.value("geometry"))
except Exception as e:
print(f"加载设置时出错: {e}")
# 设置默认值
self.conf_slider.setValue(DEFAULT_CONF_THRESHOLD)
self.circle_slider.setValue(DEFAULT_CIRCLE_RADIUS)
self.speed_slider.setValue(DEFAULT_MOVE_SPEED)
self.contour_check.setChecked(DEFAULT_SHOW_CONTOURS)
self.conf_check.setChecked(DEFAULT_SHOW_CONF)
self.bind_label.setText("未绑定")
def close_app(self):
self.save_settings()
self.aimbot.stop()
QApplication.quit()
# ==============================================
# 鼠标移动函数 (外部DLL)
# ==============================================
def move_mouse(x, y):
try:
if dll and usb_open >= 0:
dll.move(int(x), int(y))
except Exception as e:
print(f"移动鼠标失败: {e}")
# ==============================================
# 主程序
# ==============================================
def main():
# 加载鼠标控制DLL
try:
global dll, usb_open
dll = ctypes.cdll.LoadLibrary('./hiddll_x64.dll')
usb_open = dll.open_hiddev_default()
if usb_open < 0:
print("USB硬件未连接,鼠标控制将不可用")
else:
print("USB硬件已连接")
except Exception as e:
print(f"加载鼠标DLL失败: {e}")
dll = None
usb_open = -1
app = QApplication(sys.argv)
# 创建瞄准系统
aimbot = AimbotSystem()
# 创建控制面板
control_panel = ControlPanel(aimbot)
control_panel.show()
# 创建覆盖窗口
overlay = OverlayWindow(aimbot)
overlay.show()
# 启动瞄准系统线程
aimbot.start()
try:
sys.exit(app.exec_())
except KeyboardInterrupt:
aimbot.stop()
if dll and usb_open >= 0:
dll.close_hiddev()
if __name__ == "__main__":
main()
幫我合進裡面給我全部代碼