PyDroidCTRL


NamePyDroidCTRL JSON
Version 1.2.1 PyPI version JSON
download
home_pageNone
SummaryControl android with python
upload_time2024-09-04 17:22:20
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT
keywords python android adb
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyDroidCTRL

The **Android Device Controller** is a Python-based utility for controlling and interacting with Android devices via ADB. This project provides a convenient set of tools for automating tasks such as taking screenshots, simulating touch gestures, typing text, streaming the device's screen to your computer, and retrieving detailed device information.

## Features

- **Retrieve Device Information**: Get detailed information about the connected Android device.
- **Execute Shell Commands**: Run shell commands directly on the device.
- **Screenshot**: Capture and save the current screen of the Android device.
- **Tap**: Simulate a tap on the device screen at specified coordinates.
- **Swipe**: Simulate a swipe gesture on the device screen from a start to an end point.
- **Type Text**: Simulate typing text on the device.
- **Stream**: Stream the Android device's screen to your computer using `scrcpy` (now fully asynchronous).

## Requirements

- Python 3.x
- ADB (Android Debug Bridge)
- [scrcpy](https://github.com/Genymobile/scrcpy) (for streaming the device's screen, optional)

## Installation

1. **Clone the repository**:

    ```bash
    pip install PyDroidCTRL
    cd android_controller
    ```

2. **Install required dependencies** (if any):

    ```bash
    pip install -r requirements.txt
    ```

3. **Ensure ADB is installed** and accessible from your system's PATH. You can download ADB from the [official Android website](https://developer.android.com/studio/releases/platform-tools).

4. **Ensure `scrcpy` is installed** for screen streaming functionality. You can find installation instructions for `scrcpy` [here](https://github.com/Genymobile/scrcpy).

## Usage

Create an instance of the `Controller` class with the path to the ADB executable. Then use the provided methods to interact with the device.

### Example

```python
import os
import asyncio
from android_controller import Controller

# Define paths to the adb and scrcpy executables
adb_path = os.path.join(os.path.abspath('.'), "assets", "adb.exe")
scrcpy_path = os.path.join(os.path.abspath('.'), "assets", "scrcpy.exe")

async def main():
    # Initialize the controller with the paths to adb and scrcpy executables
    controller = Controller(adb_path=adb_path, scrcpy_path=scrcpy_path)

    # Retrieve and display device information
    device = controller.getDevice()
    print(device)

    # Simulate a swipe to the home menu
    controller.swipe(
        start=(device.width // 2, device.height - 1),
        end=(device.width // 2, (device.height // 16) * 15),
        duration=50
    )
    
    # Add a slight delay between gestures
    await asyncio.sleep(0.25)

    controller.swipe(
        start=(device.width // 2, (device.height // 5) * 3),
        end=(device.width // 2, (device.height // 5) * 2),
        duration=100
    )

    # Tap on the search bar and type text
    await asyncio.sleep(0.25)
    controller.tap((device.width // 2, device.height // 14))
    await asyncio.sleep(0.25)
    controller.type_text("Hello, World!")

    # Take a screenshot and save it to a file
    screenshot_path = "scr.png"
    controller.screenshot(screenshot_path)
    print(f"Screenshot saved to {screenshot_path}")

    # Stream the device's screen to your computer
    await controller.stream(max_fps=30, bit_rate="8M", rotate=False, always_on_top=True, disable_screensaver=True, no_audio=True)

# Run the main function using asyncio
asyncio.run(main())
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "PyDroidCTRL",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "python, android, adb",
    "author": null,
    "author_email": "XoQ <xoq2988@proton.me>",
    "download_url": "https://files.pythonhosted.org/packages/4d/d6/1a93e9b0a08d42beeeef380d22ed1544945808ab75aa54b8d205970fbc73/pydroidctrl-1.2.1.tar.gz",
    "platform": null,
    "description": "# PyDroidCTRL\r\n\r\nThe **Android Device Controller** is a Python-based utility for controlling and interacting with Android devices via ADB. This project provides a convenient set of tools for automating tasks such as taking screenshots, simulating touch gestures, typing text, streaming the device's screen to your computer, and retrieving detailed device information.\r\n\r\n## Features\r\n\r\n- **Retrieve Device Information**: Get detailed information about the connected Android device.\r\n- **Execute Shell Commands**: Run shell commands directly on the device.\r\n- **Screenshot**: Capture and save the current screen of the Android device.\r\n- **Tap**: Simulate a tap on the device screen at specified coordinates.\r\n- **Swipe**: Simulate a swipe gesture on the device screen from a start to an end point.\r\n- **Type Text**: Simulate typing text on the device.\r\n- **Stream**: Stream the Android device's screen to your computer using `scrcpy` (now fully asynchronous).\r\n\r\n## Requirements\r\n\r\n- Python 3.x\r\n- ADB (Android Debug Bridge)\r\n- [scrcpy](https://github.com/Genymobile/scrcpy) (for streaming the device's screen, optional)\r\n\r\n## Installation\r\n\r\n1. **Clone the repository**:\r\n\r\n    ```bash\r\n    pip install PyDroidCTRL\r\n    cd android_controller\r\n    ```\r\n\r\n2. **Install required dependencies** (if any):\r\n\r\n    ```bash\r\n    pip install -r requirements.txt\r\n    ```\r\n\r\n3. **Ensure ADB is installed** and accessible from your system's PATH. You can download ADB from the [official Android website](https://developer.android.com/studio/releases/platform-tools).\r\n\r\n4. **Ensure `scrcpy` is installed** for screen streaming functionality. You can find installation instructions for `scrcpy` [here](https://github.com/Genymobile/scrcpy).\r\n\r\n## Usage\r\n\r\nCreate an instance of the `Controller` class with the path to the ADB executable. Then use the provided methods to interact with the device.\r\n\r\n### Example\r\n\r\n```python\r\nimport os\r\nimport asyncio\r\nfrom android_controller import Controller\r\n\r\n# Define paths to the adb and scrcpy executables\r\nadb_path = os.path.join(os.path.abspath('.'), \"assets\", \"adb.exe\")\r\nscrcpy_path = os.path.join(os.path.abspath('.'), \"assets\", \"scrcpy.exe\")\r\n\r\nasync def main():\r\n    # Initialize the controller with the paths to adb and scrcpy executables\r\n    controller = Controller(adb_path=adb_path, scrcpy_path=scrcpy_path)\r\n\r\n    # Retrieve and display device information\r\n    device = controller.getDevice()\r\n    print(device)\r\n\r\n    # Simulate a swipe to the home menu\r\n    controller.swipe(\r\n        start=(device.width // 2, device.height - 1),\r\n        end=(device.width // 2, (device.height // 16) * 15),\r\n        duration=50\r\n    )\r\n    \r\n    # Add a slight delay between gestures\r\n    await asyncio.sleep(0.25)\r\n\r\n    controller.swipe(\r\n        start=(device.width // 2, (device.height // 5) * 3),\r\n        end=(device.width // 2, (device.height // 5) * 2),\r\n        duration=100\r\n    )\r\n\r\n    # Tap on the search bar and type text\r\n    await asyncio.sleep(0.25)\r\n    controller.tap((device.width // 2, device.height // 14))\r\n    await asyncio.sleep(0.25)\r\n    controller.type_text(\"Hello, World!\")\r\n\r\n    # Take a screenshot and save it to a file\r\n    screenshot_path = \"scr.png\"\r\n    controller.screenshot(screenshot_path)\r\n    print(f\"Screenshot saved to {screenshot_path}\")\r\n\r\n    # Stream the device's screen to your computer\r\n    await controller.stream(max_fps=30, bit_rate=\"8M\", rotate=False, always_on_top=True, disable_screensaver=True, no_audio=True)\r\n\r\n# Run the main function using asyncio\r\nasyncio.run(main())\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Control android with python",
    "version": "1.2.1",
    "project_urls": {
        "Homepage": "https://github.com/XoQ2988/android_controller"
    },
    "split_keywords": [
        "python",
        " android",
        " adb"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "83a122b88d59a787ed876babc91eff49d2d5fe7309835acda33391e7e9780850",
                "md5": "6085e6044351abeb13f5520807789e43",
                "sha256": "c8a23bf1acdad531720c5556484836141b366623811d156e7056978b48622bc4"
            },
            "downloads": -1,
            "filename": "PyDroidCTRL-1.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6085e6044351abeb13f5520807789e43",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6858,
            "upload_time": "2024-09-04T17:22:19",
            "upload_time_iso_8601": "2024-09-04T17:22:19.839243Z",
            "url": "https://files.pythonhosted.org/packages/83/a1/22b88d59a787ed876babc91eff49d2d5fe7309835acda33391e7e9780850/PyDroidCTRL-1.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4dd61a93e9b0a08d42beeeef380d22ed1544945808ab75aa54b8d205970fbc73",
                "md5": "07bcb381af368e7ee573c764fb59e4e5",
                "sha256": "6610abf106356bd3915ff23e7e8254b5d976f181aa79bee06324e5771780ffe7"
            },
            "downloads": -1,
            "filename": "pydroidctrl-1.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "07bcb381af368e7ee573c764fb59e4e5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 6045,
            "upload_time": "2024-09-04T17:22:20",
            "upload_time_iso_8601": "2024-09-04T17:22:20.982782Z",
            "url": "https://files.pythonhosted.org/packages/4d/d6/1a93e9b0a08d42beeeef380d22ed1544945808ab75aa54b8d205970fbc73/pydroidctrl-1.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-04 17:22:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "XoQ2988",
    "github_project": "android_controller",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pydroidctrl"
}
        
Elapsed time: 0.33882s