An intelligent automation bot for the Piano Tiles game, built with Python. It uses real-time screen capture and computer vision to detect and tap tiles automatically — including short taps, long-press holds, and gold tiles.
- ⚡ Real-time screen capture using
mssfor ultra-low latency - 🖤 Dark tile detection via grayscale thresholding
- 🟡 Gold tile detection using RGB color analysis
- 🎵 Long tile support — holds mouse down for sustained tiles and releases at the right moment
- 🛑 Safe stop — press
Qanytime to gracefully halt the bot - 🔍 Auto start — detects and clicks the first tile to begin the game automatically
- 🐛 Debug mode — optional live window showing what the bot sees
Automation_Piano_Tiles_Bot_Demo.mp4
piano-tiles-bot/
│
├── auto_player.py # Main bot — detects and clicks tiles in real time
├── game_detection.py # Helper to visualize tile detection with bounding boxes
├── get_coordinates.py # Utility to capture your game window coordinates
├── test_capture.py # Screen capture sanity check
├── tile_detection.py # Full-screen tile detection preview
└── requirements.txt # Python dependencies
git clone https://github.com/your-username/piano-tiles-bot.git
cd piano-tiles-botpip install -r requirements.txtRun the coordinate helper and follow the on-screen instructions:
python get_coordinates.pyMove your mouse to the top-left and then bottom-right corners of the game window when prompted. Copy the output into auto_player.py under GAME_REGION.
python auto_player.pyThe bot will wait 2 seconds, then auto-detect and click the start tile. Press Q at any time to stop safely.
Open auto_player.py and adjust these values to match your setup:
| Variable | Default | Description |
|---|---|---|
GAME_REGION |
{top: 50, left: 1311, width: 534, height: 951} |
Screen region of the game window |
DARK_THRESHOLD |
65 |
Grayscale cutoff for detecting black tiles |
SCAN_Y_PERCENT |
0.80 |
Vertical scan line position (80% down the game area) |
LONG_TILE_MIN_HEIGHT |
120 |
Pixel height threshold to classify a tile as long |
RELEASE_MARGIN |
10 |
Pixels above scan line to detect tile end for release |
DEBUG |
False |
Set to True to show live detection window |
| Script | Purpose |
|---|---|
get_coordinates.py |
Interactively find and print your game window's screen coordinates |
test_capture.py |
Preview full-screen capture to verify mss is working |
tile_detection.py |
Full-screen tile detection with bounding box overlay |
game_detection.py |
Region-specific detection preview for fine-tuning |
opencv-python
numpy
mss
pyautogui
keyboard
Install all at once:
pip install -r requirements.txt
⚠️ Linux users: Thekeyboardlibrary may requiresudoto capture global hotkeys.
⚠️ macOS users: You may need to grant Accessibility and Screen Recording permissions in System Preferences.
- Screen Capture —
mssgrabs the defined game region every frame. - Grayscale Conversion — The frame is converted to grayscale for fast pixel analysis.
- Lane Scanning — The bot samples one pixel per lane at a fixed vertical scan line (80% of the game height by default).
- Tile Classification:
- If the pixel is dark → a tile is present
- If the pixel's RGB matches gold → a gold tile is present
- The tile's height is measured upward from the scan point to classify it as short or long
- Input Simulation:
- Short tile →
pyautogui.click() - Long tile →
pyautogui.mouseDown()until the tile ends, thenpyautogui.mouseUp()
- Short tile →
- Safe Exit — A global
keyboardhotkey listens forQand releases all held inputs before stopping.
This project is intended for educational and personal use only. Using bots in online games may violate the game's Terms of Service. Use responsibly.
MIT License — feel free to use, modify, and share.
Pull requests are welcome! If you find a bug or want to add a feature (e.g., combo detection, speed scaling, multi-monitor support), feel free to open an issue or PR.
Built with Python 🐍 | Powered by OpenCV 👁️ | Inspired by way too many failed Piano Tiles runs 🎵