๐ Language: English | ไธญๆ
A fully automated, infinite-loop Skill Points farming system for Forza Horizon 6. Powered by Computer Vision (OpenCV + Tesseract OCR) and Virtual Gamepad (ViGEmBus), achieving zero human intervention closed-loop farming. Comes with a Cyberpunk-styled Web UI dashboard for remote monitoring and one-click control.
- โจ Features
- ๐ Workflow
- ๐ ๏ธ Tech Stack
- ๐ Getting Started
- ๐ Usage
- ๐ Project Structure
- ๐งช Testing & CI
- ๐ Technical Details
- ๐ค Contributing
- ๐ License
| Feature | Description |
|---|---|
| ๐ 4-Stage Auto Loop | Farm โ Buy โ Upgrade โ Sell, infinite loop, sleep & farm |
| ๐๏ธ Computer Vision State Machine | Color histogram + OCR hybrid detection, identifies 10+ game UI states |
| ๐ฎ Virtual Gamepad | ViGEmBus simulates Xbox 360 controller, native-level input |
| ๐ฅ๏ธ Web UI Dashboard | Glassmorphism UI + real-time logs + QR code mobile monitoring |
| โน๏ธ Instant Stop | Thread injection technology, bot stops immediately on button click |
| ๐ Auto-Update | GitHub Releases auto-update with multi-mirror download, one-click update via Web UI or --update flag |
| ๐ก๏ธ Self-Healing Capture | BitBlt failure auto-recovery with MSS reset + window re-foreground |
| ๐ฐ Super Wheelspin Counter | Automatically tracks upgrade macro executions |
| ๐ฆ One-Click Build | PyInstaller single-file .exe, no Python required |
| ๐งช 93 Test Cases | Ruff linting + Pytest coverage, GitHub Actions CI |
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ ๐๏ธ Farm โโโโโโถโ ๐ Buy โโโโโโถโ โก Upgrade โโโโโโถโ ๐๏ธ Sell โ
โ Skill Pointsโ โ Cars โ โ Cars โ โ Cars โ
โโโโโโโโฌโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโฌโโโโโโโ
โ โ
โ โป๏ธ Infinite Loop โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| Stage | State Constant | Description |
|---|---|---|
| 1๏ธโฃ | STATE_FARM_POINTS |
OCR scans skill points โ auto-enters EventLab to farm up to 999 |
| 2๏ธโฃ | STATE_BUY_CARS |
Five-step visual navigation โ batch-purchase 33 Subaru Impreza 22B-STIs |
| 3๏ธโฃ | STATE_UPGRADE_CARS |
Select each car with NEW tag โ spend skill points on skill tree |
| 4๏ธโฃ | STATE_TRASH_CARS |
Batch-remove upgraded Imprezas (keeping S2 main car) |
| Category | Technology | Purpose |
|---|---|---|
| Vision Engine | OpenCV, Tesseract OCR | Image processing, text recognition, color detection |
| Numerics | NumPy | Histogram comparison, image matrix operations |
| Screen Capture | MSS | High-performance cross-platform screenshots |
| Gamepad | VGamepad + ViGEmBus | Virtual Xbox 360 controller input |
| Web Server | Flask + Flask-SocketIO | Real-time Web UI control panel |
| Frontend | Vanilla JS + CSS3 | Glassmorphism dashboard, WebSocket live logs |
| Testing | Pytest + Ruff | Unit testing + code quality checks |
| Packaging | PyInstaller | One-click single-file executable build |
| CI/CD | GitHub Actions | Automated testing + Release publishing |
โ ๏ธ The following software must be installed before running
| Software | Version | Download | Notes |
|---|---|---|---|
| Python | 3.10+ | python.org | Check "Add to PATH" during install |
| Tesseract OCR | 5.x | Download | Check "Add to PATH" during install |
| ViGEmBus | Latest | Download | Reboot required after install |
# 1. Clone the repository
git clone https://github.com/hypoxic127/FH6-AFK.git
cd FH6-AFK
# 2. One-click install (auto-creates venv + installs dependencies)
python setup.py
# 3. Launch (Web UI mode)
python main_bot.py --webBefore starting the bot, ensure the following:
- Game language must be set to English โ OCR depends on English text
- Windowed mode โ Windowed or Borderless Windowed (recommended: 2560ร1440)
- Purchase main car โ
1998 Subaru Impreza 22B-STI Version - Install S2 tune โ Any S2-class tune (PI badge = blue)
- Favorite the EventLab blueprint โ Share code
890169683 - Enable Auto-Steering โ Go to
Settings โ Difficulty โ Auto-Steering: ON. The bot relies on auto-steering for autonomous driving in EventLab
โ ๏ธ Important: The S2 blue PI badge on the main car is the sole indicator the program uses to distinguish "keep" vs "deletable" cars. Make sure your main car has an S2 tune applied.
python main_bot.py --web # Default port 6800
python main_bot.py --web --port 8080 # Custom portOpen http://localhost:6800 in your browser to access the control panel:
- ๐ฏ Live Status โ Current stage, loop count, runtime, super wheelspin count
- ๐ Progress Bar โ Visual 4-stage progress indicator
- โ๏ธ Stage Selector โ Start from any stage via dropdown
- ๐ Live Log Terminal โ Syntax-highlighted real-time log stream
- ๐ฑ QR Remote Monitoring โ Scan QR code to monitor from your phone
- ๐ Auto-Update โ Version badge + check for updates button + one-click update with progress bar
The bot automatically checks for new releases on startup and notifies you:
# Manual update via CLI
FH6AutoBot.exe --update
# Skip update check (e.g. for autostart scenarios)
FH6AutoBot.exe --skip-update --webIn Web UI: click the ๐ button in the header, or use the โฌ๏ธ Update Now button when a new version banner appears.
python main_bot.py| Option | Function | When to Use |
|---|---|---|
[0] |
๐ Auto loop (full cycle) | Main menu โ full 4-stage infinite loop |
[1] |
๐๏ธ Farm Skill Points | Main menu โ enter EventLab |
[2] |
๐ Buy Cars | Main menu โ batch purchase Imprezas |
[3] |
โก Upgrade Cars | Main menu โ spend skill points |
[4] |
๐๏ธ Sell Cars | In garage, Subaru brand selected |
[5] |
โญ๏ธ Skip Buy loop | When garage already has un-upgraded cars |
python packaging/build.pyProduces dist/FH6AutoBot.exe โ portable, no Python needed (Tesseract & ViGEmBus still required).
๐ก Tip: Push a git tag (e.g.
git tag v1.2.0 && git push --tags) to auto-trigger GitHub Actions build and publish to the Releases page.
FH6_AutoBot/
โ
โโโ main_bot.py # ๐ Entry point (Terminal / Web UI)
โ
โโโ engine/ # ๐ง Perception Engine
โ โโโ ocr.py # Computer vision (OCR + color detection)
โ โโโ state_detect.py # Game state detector (histogram + OCR hybrid)
โ โโโ event_bus.py # Event bus (log/state push to Web UI)
โ โโโ runtime.py # PyInstaller runtime path resolution
โ โโโ version.py # Single source of truth for app version
โ โโโ updater.py # GitHub Releases auto-update engine
โ โโโ i18n.py # Bilingual string table (en/zh)
โ โโโ utils.py # Logging / window ops / gamepad / MSS capture
โ
โโโ macro/ # ๐ฎ Macro Operations
โ โโโ master_loop.py # Master state machine (4-stage loop engine)
โ โโโ core.py # Infrastructure: screenshots, logging, constants
โ โโโ navigation.py # Menu navigation / visual braking / return-to-garage
โ โโโ purchase.py # 5-step Impreza purchase navigation
โ โโโ garage.py # Garage grid: select / delete / main car nav
โ โโโ upgrade.py # Upgrade macro (Cannot Afford detection)
โ
โโโ farm/ # ๐ EventLab Farming
โ โโโ skills.py # Visual state machine (auto-drive + finish detection)
โ
โโโ web/ # ๐ Web UI Control Panel
โ โโโ server.py # Flask + SocketIO server
โ โโโ state_manager.py # Global state manager
โ โโโ static/ # Frontend assets
โ โโโ index.html # Dashboard page
โ โโโ style.css # Cyberpunk theme styles
โ โโโ app.js # WebSocket client logic
โ
โโโ packaging/ # ๐ฆ Build & Packaging
โ โโโ build.py # One-click PyInstaller build script
โ โโโ FH6AutoBot.spec # PyInstaller spec (--onefile)
โ โโโ hook_utf8.py # Runtime hook (Windows UTF-8 fix)
โ
โโโ tests/ # ๐งช Unit Tests (93 cases)
โโโ tools/ # ๐ง Dev utilities (not packaged)
โ
โโโ .github/workflows/
โ โโโ ci.yml # CI (Ruff check + Pytest)
โ โโโ release.yml # Release (PyInstaller โ GitHub Release)
โ
โโโ setup.py # โ๏ธ One-click environment setup
โโโ requirements.txt # ๐ Python dependencies
โโโ ruff.toml # ๐ Ruff linter config
โโโ pytest.ini # ๐งช Pytest config
# Run all tests
python -m pytest
# Lint check
python -m ruff check .
# Format check
python -m ruff format --check .| CI Job | Trigger | Description |
|---|---|---|
| Lint | Push / PR | Ruff lint + format validation |
| Test | Push / PR | 93 test cases (ubuntu-latest) |
| Release | v* tag |
PyInstaller build โ GitHub Release (auto-sync version) |
- Histogram + OCR Hybrid โ
StateDetectoruses color distribution features for fast candidate screening, then OCR for precise verification - PI Badge Color Detection โ HSV color space analysis: blue = S2 main car (keep), orange = deletable
- Dual PSM Mode โ Uses PSM 8 (single word) + PSM 7 (single line), picks the result with most digits
- OTSU Adaptive Thresholding โ Prevents single-digit zero-padding errors
- Zero Skill Points Fallback โ Detects "No Skill Points Available" text
- Typewriter Traversal โ Column by column, top to bottom (3รN grid)
- Triple Verification โ OCR keywords (2/3 match) + NEW yellow tag + LEGENDARY orange rarity
- Cannot Afford Detection โ Auto-dismisses popup, stops purchasing
- PyInstaller --onefile โ Single ~50MB executable
- Runtime Path Layer โ
engine/runtime.pyunified path resolution (dev/packaged dual-mode) - UTF-8 Console Fix โ
hook_utf8.pyresolves Chinese log garbling on Windows
- Integer Tuple Version Comparison โ
(1,5,10) > (1,5,9), no string comparison bugs - Transactional File Replacement โ Rollback on failure (never bricks the installation)
- Multi-Mirror Download โ Direct GitHub โ ghproxy fallback chain (3 mirrors)
- Infinite Restart Prevention โ Filters
--updatefromsys.argvbefore restarting - Rate Limit Protection โ 1-hour API cache, respects GitHub's 60 req/hr limit
- Global Update Lock โ Prevents concurrent downloads from Web UI + CLI
- BitBlt Failure Recovery โ Auto-resets MSS instance when GDI device context is corrupted
- Window Re-Foreground โ Pulls game window back to front after capture failure
- Web UI Stop/Start Safe โ MSS reset on bot stop prevents stale handle leaks
Contributions are welcome! Please follow this workflow:
- Fork this repository
- Create a feature branch (
git checkout -b feat/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feat/amazing-feature) - Open a Pull Request
- ๐ Code style: PEP 8 (enforced by Ruff)
- ๐ท๏ธ Commit format: Conventional Commits (
feat/fix/docs/refactor/chore) - โ All PRs must pass CI checks (Lint + Test)
This project is for learning and personal use only.
If this project helps you, please give it a โญ Star!
Made with โค๏ธ by hypoxic127