An AutoHotkey script that automates Hearthstone Battlegrounds matches by continuously starting new games, selecting random heroes, and restarting after death.
This script was developed for a Fiverr client in 2022 to automate the process of:
- Starting Hearthstone Battlegrounds matches
- Randomly selecting heroes from available options
- Letting the game play out until death
- Automatically restarting the process
- Handling various game states and error conditions
The script is designed for 1920x1080 resolution and uses pixel detection to navigate through the game interface.
- Fully Automated Loop: Continuously starts new games and restarts after death
- Smart Detection: Uses pixel color matching to identify UI elements
- Error Handling: Detects and handles game errors, disconnections, and pop-ups
- Random Selection: Randomly chooses between 2-4 available heroes
- Visual Debug Mode: Optional square overlays to verify detection regions
- Logging: Comprehensive logging of all actions and errors
- Game Counter: Tracks number of games played and total runtime
- Resolution: 1920x1080 (hardcoded for this resolution)
- Game: Hearthstone (Battlegrounds mode)
- Software: AutoHotkey (v1.1 or later)
- Operating System: Windows
- Install AutoHotkey if not already installed
- Download all script files:
HearthStone - queve and die n5(main script)logFile.ahk(logging functions - included via #Include)resources/deathScreenPurple.jpg(image for death screen detection)
- Create an
imgfolder in the script directory for error screenshots - Configure Hearthstone to run in windowed mode at 1920x1080
| Hotkey | Function |
|---|---|
Ctrl+1 |
Toggle automation on/off |
Ctrl+F12 |
Toggle debug squares (shows detection regions) |
2 |
Test death detection function |
- Launch Hearthstone and navigate to the Battlegrounds lobby
- Run the AutoHotkey script
- Press
Ctrl+1to start the automation - The script will begin cycling through games automatically
- Press
Ctrl+1again to stop after the current game completes - Press
Ctrl+F12to hide debug squares if visible
The script follows this workflow:
- Initial Detection: Verifies Battlegrounds button is visible
- Start Game: Clicks Play button and waits for hero selection
- Hero Selection: Randomly selects a hero (from available slots 2-4)
- Gameplay: Waits for game to finish (up to 25 minutes timeout)
- Death Detection: Detects when hero dies using image/color detection
- Reset: Returns to lobby and starts new game
- Error Handling: Detects and resolves common errors (disconnects, pop-ups)
The script defines multiple screen regions for detecting game states:
- Battlegrounds button
- Play button
- Hero selection interface
- Hero choice buttons (1-4)
- Confirm button
- Death screen indicators
- Error notification areas