β οΈ Disclaimer: This project is intended for educational purposes only. Do not use this bot in real Clash of Clans accounts β doing so may violate Supercellβs Terms of Service and could result in your account getting banned. The author is not responsible for any misuse of this tool.
A Python automation script that donates troops in Clash of Clans using screen recognition with OpenCV
, GUI automation with PyAutoGUI
, and human-like interactions to reduce detection risk. This bot works by detecting request templates on screen and clicking the donation buttons intelligently.
- π§ Image recognition using OpenCV for troop and donation button detection
- π Human-like clicks and movement using sigmoid curve pathing
- π€ Real-time screen scanning and troop response loop
- πΌοΈ Visual overlay with troop request detection windows
- π₯΅ Multi-threaded design for efficient operation
- πΆοΈ Works on screen-shared or emulator-based Clash of Clans sessions
π coc-bot/
βββ coc.py # Main bot script (entry point)
βββ draw.py # Tkinter-based debug visualization
βββ human_like.py # Human-like movement and click simulation
βββ donate_file/ # Folder with troop template images (e.g., loon.png, light.png)
βββ donate.png # Image template of the donation button
Install the required Python packages using pip:
pip install opencv-python pyautogui numpy
β οΈ tkinter
comes preinstalled with most Python distributions. If not, install it manually (especially on Linux).
-
Prepare your environment:
- Run Clash of Clans on an emulator or screen-shared device in a fixed screen resolution (e.g., 1920x1080).
- Position the game so that troop requests appear in the upper-left region of the screen.
-
Add troop templates:
- Place cropped grayscale images of troop requests (e.g.,
loon.png
,light.png
) in thedonate_file/
directory. - Make sure each image matches the screen size and resolution precisely.
- Place cropped grayscale images of troop requests (e.g.,
-
Run the bot:
python coc.py
The bot will:
- Continuously scan for troop requests
- Detect and click donation buttons
- Log activity to the console
- Draw visual boxes to show detection zones
find_template()
scans specific screen regions for matching troop request templates.- If a match is found, it looks for the donate button nearby.
- Clicks are performed via
human_like.py
, which simulates realistic motion paths. draw.py
draws a temporary red box to show what part of the screen is being scanned.
- π Use at your own risk β while this mimics human behavior, automation tools may still be against game ToS.
- π₯οΈ This bot is not universal β you must use proper screen resolution, or the templates won't match.
- π§ͺ Test in sandboxed or secondary accounts before using on your main.
Contributions are welcome! Feel free to open issues or pull requests.