An intelligent automation bot that solves multiplication problems in quizzes/games using OCR and precise mouse control.
- 🎯 Accurate OCR processing with Tesseract v5+
- ⚙️ Configurable screen regions for question/answer detection
- 🤖 Human-like mouse movements and click timing
- 🔄 Automatic pop-up detection ("Back to Game" handling)
- 📸 Debug image saving for OCR optimization
- � Robust error recovery and retry mechanisms
- 🧮 Supports integer multiplication problems (e.g., "12*5")
- 📊 Confidence-based answer matching system
- ⏲️ Randomized delays to mimic human behavior
- Python 3.8+
- Tesseract OCR ≥5.0 (Windows installer)
- Required Python packages:
pip install pyautogui pytesseract Pillow imagehash
- Install Tesseract and note its installation path
- Clone repository:
git clone https://github.com/yourusername/multiplication-solver.git cd multiplication-solver
- Edit script configuration:
# -*- coding: utf-8 -*- # --- Configuration --- MUST BE EDITED --- tesseract_path = r'C:\Program Files\Tesseract-OCR\tesseract.exe' # Your Tesseract path # Adjust these regions using Windows' Snipping Tool coordinates: QUESTION_REGION = (880, 260, 300, 100) # Region containing multiplication problem OPTIONS_REGIONS = [ # Answer option regions (900, 370, 200, 50), (900, 440, 200, 50), (900, 520, 200, 50), (900, 600, 200, 50) ] BACK_TO_GAME_REGION = (900, 700, 200, 50) # Pop-up button region
- Screen Capture: Uses PIL.ImageGrab to capture configured regions
- Image Preprocessing:
- Grayscale conversion
- Threshold binarization (adjustable)
- Optional inversion
- OCR Processing:
- Custom Tesseract config for numbers/symbols
- Text cleaning and validation
- Calculation:
- Parses multiplication problems
- Computes correct answer
- Answer Matching:
- Numeric comparison with tolerance
- Fallback strategies
- Execution:
- Humanized mouse movements
- Randomized delays
- Pop-up handling
Common Issues:
- Incorrect OCR results:
- Adjust
PREPROCESSING_THRESHOLD
(180 default) - Enable
SAVE_DEBUG_IMAGES = True
- Check debug images in
ocr_debug_images/
- Adjust
- Tesseract not found:
- Verify
tesseract_path
in configuration - Add Tesseract to system PATH
- Verify
Performance Tips:
- Keep target window visible
- Disable animations in target application
- Use consistent window positioning
- Start with large debug thresholds (200+)
- Currently only supports integer multiplication
- Requires static window positioning
- Dependent on screen resolution (1920x1080 recommended)
- May require calibration for different font styles
This project is intended for educational purposes only. Always respect application terms of service and local laws when implementing automation solutions. Use at your own risk.