Game Development 6 min read

Build a Python ADB Bot to Auto‑Farm Gold in Honor of Kings

This tutorial explains how to set up ADB and Python, capture screen coordinates, and run a scripted loop that automatically taps specific points in Honor of Kings to repeatedly collect gold, including troubleshooting tips and packaging the script as an executable.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Build a Python ADB Bot to Auto‑Farm Gold in Honor of Kings

Principle

The game script works by skipping manual steps and directly sending tap commands at specific screen coordinates at the right moments.

Environment Setup

ADB Tool (Connect Phone to PC)

Download ADB from adbshell.com or other sources and install it until the device appears as shown.

Python and IDE (Optional)

Install Python and an IDE of your choice; the setup is similar to the ADB installation.

Gold Farming Steps

1. Connect phone via USB and enable Developer Mode

2. Start ADB

Error 1: Port 5037 occupied

netstat -ano | findstr "5037"
taskkill /pid <process_id> /f

Error 2: Missing DLL or Developer Mode not enabled

# Option 1: copy adb.exe and AdbWinApi.dll to C:\WINDOWS\System32
# Option 2: copy them to C:\WINDOWS\SysWOW64

3. Open Honor of Kings, capture screenshots, and note pixel coordinates

Example: the "Wanxiang Tiangong" button is at (1755, 793). Use adb shell input tap 1755 793 to click it. Similar coordinates are recorded for other actions.

4. Script

# -*- coding: utf-8 -*-
# @Author  : daruida
# @Time    : 2021/1/8 15:38
import os
from time import sleep

# click method
def click_screen(x, y):
    os.system('adb shell input tap {} {}'.format(x, y))

def repeat(zidong):
    print('开始挑战')
    # challenge
    click_screen(1697, 861)
    sleep(10)
    # skip
    print('点击跳过')
    click_screen(2175, 45)
    sleep(1)
    # auto
    if zidong == 0:
        print('点击自动')
        click_screen(2117, 39)
        zidong = 1
    # finish
    sleep(60)
    print('打完了')
    click_screen(2175, 45)
    sleep(10)
    # continue
    print('挑战完成

')
    click_screen(1000, 500)
    sleep(1)
    # next challenge
    print('再次挑战

')
    click_screen(2001, 1011)
    sleep(1)
    repeat(zidong)

if __name__ == '__main__':
    zidong = 0
    print('刷金币初始化....')
    click_screen(1755, 793)  # Wanxiang Tiangong
    sleep(1)
    click_screen(211, 275)   # Adventure mode
    sleep(1)
    click_screen(1231, 557)  # Challenge
    sleep(2)
    print('通天塔')
    click_screen(1393, 475)  # Tower
    sleep(1)
    click_screen(1677, 675)  # Master level
    sleep(1)
    click_screen(1791, 939)  # Next step
    print('刷金币重复阶段...')
    repeat(zidong)

You can adjust the sleep durations if your network or device is faster.

5. Package as EXE

Run pyinstaller -F your_script.py to create a standalone executable.

6. Run

Connect the phone, launch Honor of Kings to the initialization screen, and execute the generated EXE. If errors occur, simply restart the program.

Test

Using a combination like Sun Ben + Kuang Tie + Xiao Jin Jin, the bot can earn over 1000 gold per hour after a 1‑minute warm‑up.

Feel free to discuss adjustments for different hero combos.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythonADBHonor of KingsBotGame Automation
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.