Skip to content

Repository files navigation

Game Button Auto Clicker

Automatic game button clicker using Python and image recognition technology.

Features

  • ✅ Automatic Image Recognition - OpenCV template matching to locate buttons
  • ✅ Smart Retry Mechanism - Auto-stop after 3 consecutive failures
  • ✅ Two-Step Workflow - Spin button → Wait 5s → Confirm button
  • ✅ Configurable Click Rounds - Default 50, customizable via command line
  • ✅ Isolated Conda Environment - No dependency conflicts
  • ✅ Detailed Logging - Records time, position, and button type for each click

Workflow

Each complete round consists of 3 steps:

  1. Step 1: Click spin button (button_1.png or button_2.png)
  2. Step 2: Wait 5 seconds
  3. Step 3: Click confirm button (button_3.png)

After completing a round, wait 5 seconds (configurable), then start the next round.

Installation

Prerequisites

  • Conda (Anaconda or Miniconda) - Assumed to be installed

Setup Steps

Windows:

# Run setup script to create conda environment
set_up.bat

Linux/Mac:

# Make scripts executable
chmod +x set_up.sh run.sh

# Run setup script
./set_up.sh

This will:

  • Create an isolated conda environment named game_clicker (Python 3.11)
  • Install all required dependencies (OpenCV, PyAutoGUI, Pillow, NumPy)
  • Configure the environment for running the auto-clicker

Prepare Button Images

  1. Open the game interface and ensure buttons are visible
  2. Use screenshot tool (Win + Shift + S) to capture button images
  3. Save images to images/ directory:
    • button_1.png - First spin button (priority match)
    • button_2.png - Second spin button (alternative)
    • button_3.png - Confirm button (appears after spinning)

Screenshot Tips:

  • Capture only the button itself, avoid excessive background
  • Save as PNG format for clarity
  • Use actual button size

Usage

Quick Start

Windows:

# Use default settings (50 rounds)
run.bat

# Custom number of rounds
run.bat --max-clicks 100

# Test mode (10 rounds)
run.bat -n 10

Linux/Mac:

# Use default settings
./run.sh

# Custom number of rounds
./run.sh --max-clicks 100

# Test mode
./run.sh -n 10

Command Line Options

python auto_clicker.py              # Default (50 rounds)
python auto_clicker.py --max-clicks 100   # 100 rounds
python auto_clicker.py -n 10        # 10 rounds (testing)
python auto_clicker.py --debug      # Enable debug logging

Note: The conda environment game_clicker will be automatically activated when using run.bat or run.sh

Configuration

Main configuration in config.py:

Setting Default Description
CLICK_INTERVAL 5 Interval between rounds (seconds)
STEP_WAIT_TIME 5 Wait time between Step 1 and Step 3 (seconds)
DEFAULT_MAX_CLICKS 50 Default maximum rounds
MAX_RETRIES 3 Maximum consecutive retries before stopping
CONFIDENCE 0.8 Image matching confidence threshold (0.0-1.0)

Output Example

============================================================
Starting auto-clicker - Max rounds: 50
Workflow: Spin → Wait 5s → Confirm → Wait 5s
Will stop after 3 consecutive failures
============================================================
Starting in 3 seconds...

[Round 1/50] Step 1: Looking for spin button...
✓ Click button1 - Position: (800, 450)
Step 2: Waiting 5 seconds...
Step 3: Looking for confirm button...
✓ Click button3 - Position: (640, 360)
✓ Round 1 completed successfully
Waiting 5 seconds before next round...

[Round 2/50] Step 1: Looking for spin button...
...

============================================================
Execution completed! Total rounds: 50
============================================================

Troubleshooting

Missing Button Images

If you see "Missing button image files" error:

  1. Check that images/ directory contains all 3 PNG files:
    • button_1.png
    • button_2.png
    • button_3.png
  2. Verify images are in PNG format
  3. See images/README.txt for detailed instructions

Button Not Found

If "Failed to find button" error occurs:

  1. Check game window - Ensure game is open and buttons are visible
  2. Verify screenshots - Re-capture button images matching current interface
  3. Screen resolution - Ensure resolution matches when screenshots were taken
  4. Adjust confidence - Lower CONFIDENCE value in config.py (e.g., 0.7)

Debug Mode

Enable detailed matching information:

python auto_clicker.py --debug

Conda Environment Issues

If conda environment fails to activate:

# Manually activate environment
conda activate game_clicker

# Re-run setup if needed
set_up.bat  # Windows
./set_up.sh # Linux/Mac

Tech Stack

  • Python 3.11 (via Conda)
  • OpenCV - Image processing and template matching
  • PyAutoGUI - Mouse control and clicking
  • Pillow - Screen capture
  • NumPy - Numerical computing

Project Structure

game/
├── auto_clicker.py      # Main program
├── config.py            # Configuration file
├── requirements.txt     # Python dependencies
├── README.md            # Documentation
├── set_up.bat           # Windows setup script
├── set_up.sh            # Linux/Mac setup script
├── run.bat              # Windows run script
├── run.sh               # Linux/Mac run script
└── images/              # Button image directory
    ├── README.txt       # Image instructions
    ├── button_1.png     # First spin button template
    ├── button_2.png     # Second spin button template
    └── button_3.png     # Confirm button template

Important Notes

⚠️ Requirements

  1. Game window must remain visible (do not minimize)
  2. Do not change screen resolution during execution
  3. Keep button positions consistent
  4. Must have Conda installed (Anaconda or Miniconda)
  5. Recommended: Test with -n 10 first before full run

Environment Management

# Activate environment manually (if needed)
conda activate game_clicker

# Deactivate environment
conda deactivate

# Remove environment (if needed)
conda env remove -n game_clicker

# Recreate environment
set_up.bat  # or ./set_up.sh

License

MIT License

Changelog

v2.0.0 (2026-02-13)

  • ✨ Two-step workflow: Spin → Wait → Confirm
  • ✨ Conda environment support
  • ✅ Added button_3.png for confirm button
  • ✅ Updated all documentation to English
  • ✅ Simplified setup scripts (assumes conda installed)

v1.0.0 (2026-02-13)

  • ✨ Initial release
  • ✅ Dual button template matching
  • ✅ Smart retry mechanism
  • ✅ Configurable click rounds

About

英魂之刃糖画自动点击

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages