added function for uploading a screenshot via Drag and Drop

This commit is contained in:
2025-01-19 12:31:36 +01:00
parent 0af1a27dcd
commit af4b377bb6
3 changed files with 155 additions and 101 deletions

View File

@@ -1,24 +1,23 @@
# ADB Unlock, Screenshot & Scrcpy Tool
A simple Python GUI application that uses:
- **ADB** to unlock an Android device and take a screenshot
- **Scrcpy** to display and control an Android device (non-blocking)
- Tkinter for the GUI
A user-friendly Python GUI application for managing Android devices. This tool allows you to unlock devices, take screenshots, mirror the device screen, and transfer photos with drag-and-drop functionality.
## Features
- **Unlock Devices**: Easily unlock an Android device using ADB.
- **Take Screenshots**: Capture and save screenshots from the connected Android device.
- **Screen Mirroring**: Use Scrcpy for real-time screen mirroring and control.
- **Photo Transfer**: Drag and drop photos to transfer them to the connected device.
## Requirements
### Software
- **Python 3** (with Tkinter installed):
- On most systems, Python 3 will already include the `tkinter` module.
- If you need to install it separately:
- Debian/Ubuntu: `sudo apt-get install python3-tk`
- macOS (Homebrew): `brew install python-tk` (though often included by default)
- Windows: `tkinter` is usually included in the official Python installer.
- **ADB** (Android SDK Platform Tools) available on your PATH.
- **Scrcpy** installed and on your PATH (for screen mirroring).
- A **`devices.json`** file in the same directory, containing your device serials.
Example `devices.json`:
- Tkinter comes bundled with most Python installations. If not, install it using the instructions below.
- **ADB** (Android Debug Bridge): Ensure it is installed and added to your system PATH.
- **Scrcpy**: Install and add it to your system PATH for screen mirroring.
- **Devices Configuration**: Create a `devices.json` file in the same directory as the script to store device serials.
#### Example `devices.json`:
```json
{
"devices": [
@@ -28,3 +27,73 @@ Example `devices.json`:
"device_serial_2"
]
}
```
### Tkinter Installation (if not already installed)
- **Debian/Ubuntu**: `sudo apt-get install python3-tk`
- **macOS** (Homebrew): `brew install python-tk` (Tkinter is usually included by default).
- **Windows**: Tkinter is typically included in the official Python installer.
### Installation of ADB and Scrcpy
- **ADB**:
- Download the Android SDK Platform Tools from [Google](https://developer.android.com/studio/releases/platform-tools).
- Add the folder containing `adb` to your system PATH.
- **Scrcpy**:
- Installation instructions for various platforms can be found on the [Scrcpy GitHub page](https://github.com/Genymobile/scrcpy).
- Add the Scrcpy binary to your system PATH.
## How to Run
1. Clone or download the repository containing this script.
2. Ensure `devices.json` is in the same directory.
3. Run the script:
```bash
python script_name.py
```
4. Follow the on-screen instructions to select a device and perform actions.
## How to Use
1. **Device Selection**:
- Select a device from the dropdown menu populated using `devices.json`.
2. **Unlock Device**:
- Click the "Unlock Device" button to unlock the selected device.
3. **Take Screenshot**:
- Enter a name for the screenshot (e.g., `screenshot.png`).
- Click the "Take Screenshot" button to save the screenshot to the default folder.
4. **Screen Mirroring**:
- Set the maximum FPS for Scrcpy (optional).
- Click "Start scrcpy" to mirror and control the device screen.
5. **Photo Transfer**:
- Drag and drop a photo file into the input field or manually provide its path.
- Click "Push Photo" to transfer the photo to the device.
## Dependencies
This project relies only on Pythons standard library:
- `json`
- `subprocess`
- `os`
- `tkinter`
### No External Python Packages Required
All required modules come bundled with Python. However, ensure:
- `adb` is installed and on your PATH.
- `scrcpy` is installed and on your PATH.
## Troubleshooting
- **ADB or Scrcpy Commands Not Found**:
- Ensure ADB and Scrcpy are installed and added to your system PATH.
- **Tkinter Module Not Found**:
- Follow the installation instructions for your operating system to install Tkinter.
- **Device Not Listed**:
- Ensure the device is connected and `adb devices` lists it.
## Contributing
Feel free to submit issues or contribute improvements to the project. Fork the repository and submit a pull request with your changes.
## License
This project is licensed under the MIT License. See the `LICENSE` file for details.