Remote Android Control with Python: Build a Simple PyAndroidControl App
This article introduces PyAndroidControl, a lightweight Android receiver that periodically uploads screenshots to a Python web server for image analysis and returns executable commands, enabling remote device control via cloud phones without needing Java/Kotlin or ADB on a PC.
Sometimes I want to write Android scripts, but using Java or Kotlin for image processing is cumbersome, and learning automation scripts feels unnecessary. While ADB works, it often requires a computer, which can be inconvenient. Cloud phones such as Hongshouzhi or Aiyuntu provide a more convenient way to run continuous tasks.
Therefore I created a basic Android-side receiver that receives control commands from a Python server, allowing remote manipulation of the Android device.
Project repository: https://github.com/nladuo/PyAndroidControl
Architecture Idea
The architecture is simple: an Android client and a web server.
The app periodically uploads screenshots to the web server. The Python backend can perform image search or other processing on these screenshots, then send back commands that the Android app executes.
Usage Instructions
1. Install PyAndroidControl App
Root permission is required for the app to control the device.
Download the latest release: https://github.com/nladuo/PyAndroidControl/releases
2. Modify the Code According to Your Needs
The provided get_commands function is intended for developers. It takes two parameters: token (a label to identify the user) and img_file (the screenshot from the Android device).
Edit the file simple-control-server/logics.py to implement your own logic.
<code>def get_commands(token, img_file):
""" analyze the screenshot and send commands back to android device """
img_file.save("tmp.png")
print(token)
# your adb shell commands
cmds = [
'input text "111"',
'input text "222"',
'input text "333"',
]
return cmds
</code>The example simply sends three ADB commands that input the strings "111", "222", and "333" at one‑second intervals.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.