Writing in the front

Sometimes I want to write android scripts for games or other things, but it’s too much trouble to write graphics in Java or Kotlin, and I don’t want to learn the script for keystroke Sprite. Adb is fine, but a lot of the time you have to use a computer, which is a little inconvenient. Feel now cloud mobile phone is more convenient, such as: red finger, love cloud rabbit this, I prefer to use the cloud mobile phone this hang up, at any time on the phone can see hang up the progress of what.

So I wrote a basic Android receiver that would receive control commands from python on the server to manipulate the Android.

Link: github.com/nladuo/PyAn…

Architectural idea

The architecture is simple, with an Android side and a WebServer side.

Method of use

1. Install PyAndroidControl APP

Because you’re manipulating the device, you need to grant the PyAndroidControl application root permission. Download at github.com/nladuo/PyAn…

2. Modify the code according to personal requirements

Here I provide a get_Commands method for developers to use. There are two parameters. The first token represents the login tag, which distinguishes the user. The second img_file represents a screenshot of the Android device.

So just modify the simple-control-server/logics.py file.

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
Copy the code

For simplicity, here is an example of autotyping “111”, “222”, and “333” per second.

rendering