๐ Language: English | ไธญๆ
An autonomous bot that plays Forza Horizon 6 with zero human input. It sees the game through computer vision (OpenCV + Tesseract OCR) and plays it through a virtual Xbox 360 controller (ViGEmBus), looping farm โ buy โ upgrade โ sell forever โ and you drive the whole thing from a real-time web dashboard, even from your phone.
Farming skill points, buying, upgrading, and selling cars โ hands-free.
Web dashboard: live stage tracking, loop & super-wheelspin counters, log stream, and a QR code for phone monitoring.
FH6 AutoBot is a closed perception โ decision โ actuation loop. Every tick it captures the game window, decides what state the game is in, and issues controller input โ no human in the loop.
flowchart LR
P["๐๏ธ Perception (see)<br/>MSS capture<br/>OpenCV + OCR<br/>color histograms"]
D["๐ง Decision (decide)<br/>4-stage state machine<br/>+ visual sub-FSMs"]
A["๐ฎ Actuation (act)<br/>Virtual Xbox 360 pad<br/>(ViGEmBus)"]
P --> D --> A
A -.->|game window| P
The codebase is four layers with a strict one-way dependency direction
(web โ macro / farm โ engine, never the reverse), so perception never depends on the UI:
| Layer | Responsibility |
|---|---|
engine/ |
Perception + infrastructure โ OCR, hybrid state detection, screen capture, gamepad, i18n, auto-updater |
macro/ |
The automation โ the master state machine plus per-stage menu macros (navigate / purchase / garage / upgrade) |
farm/ |
A self-contained visual sub-state-machine that auto-drives an EventLab race to completion |
web/ |
Flask + SocketIO server and the vanilla-JS dashboard |
Notable engineering:
- 12-pass OCR voting โ every skill-point read runs 3 preprocessing variants ร 4 Tesseract PSM modes and votes on the result, so a single bad frame can't derail it.
- Histogram + OCR hybrid state detection โ fast color-distribution screening narrows the candidates, then OCR confirms โ cheap and robust across 10+ similar menus.
- Self-healing capture โ on a BitBlt/GDI failure it resets the MSS instance and re-foregrounds the game window instead of feeding on black frames.
- Cooperative-first safe stop โ halts on a clean boundary (gamepad released, never mid-keypress); async exception injection is only a fallback when a native call is blocking.
| Feature | Description |
|---|---|
| ๐ 4-Stage Auto Loop | Farm โ Buy โ Upgrade โ Sell, infinite loop โ sleep while it farms |
| ๐ฅ๏ธ Web Dashboard | Glassmorphism UI + real-time logs + QR-code mobile monitoring |
| โน๏ธ Safe Instant Stop | Stops the bot instantly and cleanly โ gamepad released, never mid-keypress |
| ๐ Auto-Update | One-click update from the Web UI or --update, multi-mirror download |
| ๐ฐ Super-Wheelspin Counter | Automatically tracks upgrade-macro executions |
| ๐ฆ One-Click Build | PyInstaller single-file .exe, no Python required |
flowchart LR
A["๐๏ธ Farm Skill Points"] --> B["๐ Buy Cars"] --> C["โก Upgrade Cars"] --> D["๐๏ธ Sell Cars"]
D -->|"โป๏ธ Infinite Loop"| A
| 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 a NEW tag โ spend skill points on the skill tree |
| 4๏ธโฃ | STATE_TRASH_CARS |
Batch-remove upgraded Imprezas (keeping the S2 main car) |
| Category | Technology |
|---|---|
| Vision | OpenCV ยท Tesseract OCR ยท NumPy |
| Capture & Input | MSS ยท VGamepad + ViGEmBus |
| Web | Flask + Flask-SocketIO ยท Vanilla JS + CSS3 |
| Tooling | Pytest + Ruff ยท PyInstaller ยท GitHub Actions |
| Software | Version | Download | Notes |
|---|---|---|---|
| Python | 3.10+ | python.org | Check "Add to PATH" during install |
| Tesseract OCR | 5.x | Download | Install to default location (auto-detected) |
| ViGEmBus | Latest | Download | Reboot required after install |
git clone https://github.com/hypoxic127/FH6-AFK.git
cd FH6-AFK
python setup.py # creates a venv + installs dependencies
python main_bot.py --web # launch the Web UI- Set the game language to English โ OCR depends on English text
- Windowed / Borderless mode โ any 16:9 resolution works (the skill-points OCR region is tuned for 16:9). On a non-16:9 monitor or non-default HUD scale, use the Web UI Calibrate button to box the skill-points number and save your own ROI
- Buy the main car โ
1998 Subaru Impreza 22B-STI Versionand install an S2 tune (PI badge = blue) - Favorite an EventLab blueprint โ any works; the default share code
890169683yields ~10 skill points per race - Set Points / Match + Target Points in the Web UI to match your blueprint (wrong values over- or under-farm)
- Enable Auto-Steering (
Settings โ Difficulty โ Auto-Steering: ON) โ the bot relies on it to drive in EventLab
โ ๏ธ The S2 blue PI badge on the main car is the only thing the bot uses to tell "keep" from "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 for live status, the stage selector, a syntax-highlighted log
terminal, and a QR code to monitor from your phone.
FH6AutoBot.exe --update # update to the latest release
FH6AutoBot.exe --skip-update --web # skip the update check (e.g. autostart)python main_bot.py| Option | Function | When to Use |
|---|---|---|
[0] |
๐ Auto loop (full cycle) | Full 4-stage infinite loop |
[1] |
๐๏ธ Farm Skill Points | Enter EventLab |
[2] |
๐ Buy Cars | Batch purchase Imprezas |
[3] |
โก Upgrade Cars | Spend skill points |
[4] |
๐๏ธ Sell Cars | In garage, Subaru brand selected |
[5] |
โญ๏ธ Skip Buy loop | When the garage already has un-upgraded cars |
python packaging/build.py # โ dist/FH6AutoBot.exe (Tesseract & ViGEmBus still required)Indicative direction, not a promise โ ideas and PRs welcome.
- Resolution-agnostic OCR โ auto-detect the skill-points ROI, dropping the 16:9 assumption
- Dashboard analytics โ points/hour, cars processed, session history
- Multi-monitor โ pick the capture display in the Web UI
- More languages โ localization beyond en/zh
Contributions are welcome โ see CONTRIBUTING.md.
FH6 AutoBot is provided for educational and personal use only. Automating gameplay may violate the game's Terms of Service and could result in penalties or an account ban โ use it at your own risk. This is an independent, fan-made tool, not affiliated with, endorsed by, or associated with the developers or publisher of any game it interacts with. The authors accept no liability for any consequences of its use.
For learning and personal use only โ see LICENSE.
If this project helps you, please give it a โญ Star โ it genuinely helps others discover it.
Made with โค๏ธ by hypoxic127