Python Game Bot Framework β€” Computer Vision, Memory Reading & Automation for Any PC Game (Open Source Template)

Blacksec

Administrator
Staff member
🐍 PYTHON GAME BOT FRAMEWORK 🐍Computer Vision β€’ Memory Reading β€’ Automation β€’ Open Source β€’ Template β€’ Tutorials

⚑ BOT FRAMEWORK: Complete Python framework for building game bots. Supports computer vision (object detection via YOLO), memory reading (Windows API), and input automation (mouse/keyboard). Cross-game compatible template β€” adapt to any game.

FRAMEWORK COMPONENTS
ModulePurposeLibraryComplexityPerformance
Screen CaptureCapture game window in real-timedxcam, mss, pyautoguiLow60-240 FPS
Object DetectionDetect enemies, items, objects on screenYOLOv8, OpenCVMedium30-60 FPS (YOLO)
Memory ReaderRead game memory for position, health, ammoReadProcessMemory, pymemHigh< 1ms per read
Input ControllerSimulate mouse/keyboard inputpyautogui, pydirectinputLow< 1ms per action
PathfindingNavigate game worldCustom A*/NavMeshMediumReal-time
Decision EngineState machine for bot behaviorCustom state machineMediumReal-time
LoggingDebug and performance logginglogging + customLowMinimal
Anti-DetectionRandom delays, human-like movementCustom curvesMediumMinimal overhead

MEMORY READING EXAMPLE
Code:
import ctypes
import ctypes.wintypes

class MemoryReader:
    def __init__(self, process_name):
        self.process_name = process_name
        self.process_handle = None
        self.base_address = None
        self.OpenProcess = ctypes.windll.kernel32.OpenProcess
        self.ReadProcessMemory = ctypes.windll.kernel32.ReadProcessMemory
        self.PROCESS_ALL_ACCESS = 0x1F0FFF
    
    def attach(self):
        # Find process by name
        import psutil
        for proc in psutil.process_iter(['pid', 'name']):
            if proc.info['name'].lower() == self.process_name.lower():
                pid = proc.info['pid']
                self.process_handle = self.OpenProcess(
                    self.PROCESS_ALL_ACCESS, False, pid
                )
                # Get base address
                for module in proc.memory_maps():
                    if module.path and self.process_name in module.path:
                        self.base_address = int(module.addr, 16)
                        break
                return True
        return False
    
    def read_int(self, address, offset=0):
        addr = address + offset
        buffer = ctypes.c_int(0)
        bytes_read = ctypes.c_size_t(0)
        self.ReadProcessMemory(
            self.process_handle, addr, 
            ctypes.byref(buffer), ctypes.sizeof(buffer), 
            ctypes.byref(bytes_read)
        )
        return buffer.value
    
    def read_float(self, address, offset=0):
        addr = address + offset
        buffer = ctypes.c_float(0.0)
        bytes_read = ctypes.c_size_t(0)
        self.ReadProcessMemory(
            self.process_handle, addr,
            ctypes.byref(buffer), ctypes.sizeof(buffer),
            ctypes.byref(bytes_read)
        )
        return buffer.value
    
    def read_multilevel(self, base, offsets):
        """Read with multi-level pointer chain"""
        addr = base
        for i, offset in enumerate(offsets):
            if i < len(offsets) - 1:
                addr = self.read_int(addr, offset)
            else:
                return self.read_float(addr, offset)
    
    def close(self):
        if self.process_handle:
            ctypes.windll.kernel32.CloseHandle(self.process_handle)

# Usage example:
# reader = MemoryReader("cs2.exe")
# if reader.attach():
#     # Read health (example: pointer chain 0x1234 β†’ 0x56 β†’ 0x78)
#     health = reader.read_multilevel(reader.base_address + 0x1234, [0x56, 0x78])
#     print(f"Health: {health}")

COMPUTER VISION BOT TEMPLATE
Code:
import cv2
import numpy as np
from ultralytics import YOLO
import pydirectinput
import time

class VisionBot:
    def __init__(self, model_path='yolov8n.pt'):
        self.model = YOLO(model_path)
        self.screen = dxcam.create()
        self.running = False
    
    def start(self, region=None):
        self.running = True
        while self.running:
            # Capture screen
            frame = self.screen.grab(region=region)
            if frame is None:
                continue
            
            # Detect objects
            results = self.model(frame, conf=0.5)
            
            # Process detections
            for result in results[0].boxes:
                x1, y1, x2, y2 = map(int, result.xyxy[0])
                cls = int(result.cls[0])
                conf = float(result.conf[0])
                
                if cls == 0:  # Player/enemy class
                    # Aim at center of detected object
                    target_x = (x1 + x2) // 2
                    target_y = (y1 + y2) // 2
                    
                    # Move mouse towards target
                    screen_center_x = 960  # 1920/2
                    screen_center_y = 540  # 1080/2
                    
                    dx = target_x - screen_center_x
                    dy = target_y - screen_center_y
                    
                    # Smooth movement with human-like curve
                    if abs(dx) > 5 or abs(dy) > 5:
                        smooth_x = int(dx * 0.3 + (dx * 0.1))
                        smooth_y = int(dy * 0.3 + (dy * 0.1))
                        pydirectinput.moveRel(smooth_x, smooth_y)
                        
                        # Random delay between actions
                        time.sleep(0.05 + random.random() * 0.02)
                        
                        # Click if close enough to target
                        if abs(dx) < 20 and abs(dy) < 20:
                            pydirectinput.click()
                            time.sleep(0.2)
            
            # Small delay to control loop speed
            time.sleep(0.01)  # ~100 FPS loop
    
    def stop(self):
        self.running = False

DOWNLOAD
Code:
Full framework: [URL="https://mega.nz/file/BlackSec_PythonBotFramework_2026"]File on MEGA[/URL]
Size: 250 MB (includes YOLO model + dependencies)
Password: BotFramework2026
Includes: Source code + trained models + example bots + setup script + video tutorials

🐍 Build bots that play for you. Python + computer vision = unbeatable automation. 🐍
 
Top