Android Screen Control Tool - 黑屏而不锁屏的 Android 屏幕控制工具
Project description
asctl - Android Screen Control Tool
中文 | English
黑屏而不锁屏的 Android 屏幕控制工具,基于 scrcpy 实现。
功能特性
- ✅ 黑屏而不锁屏:关闭屏幕但保持设备唤醒
- ✅ 保持唤醒:修改系统设置防止设备休眠
- ✅ 简洁高效:只建立控制连接,不处理视频流
- ✅ Termux 友好:纯 Python 实现,适合 Termux 环境
- ✅ 自动化友好:提供 CLI 和 Python API
安装
pip install asctl
或从源码安装:
cd asctl
pip install .
使用方法
命令行使用
# 关闭屏幕(保持设备唤醒)
asctl --off
# 打开屏幕
asctl --on
# 启用保持唤醒
asctl --stay-awake
# 禁用保持唤醒
asctl --no-stay-awake
# 指定设备(如果有多个设备)
asctl --device <device_id> --off
Python API 使用
from asctl import AndroidScreenControl
# 创建控制器
controller = AndroidScreenControl()
# 关闭屏幕
controller.turn_screen_off()
# 打开屏幕
controller.turn_screen_on()
# 设置保持唤醒
controller.set_stay_awake(True)
工作原理
asctl 基于 scrcpy 的实现,通过以下步骤实现黑屏而不锁屏:
- 推送 scrcpy server 到设备
- 启动 server(只启用控制,关闭视频流)
- 建立控制 socket 连接
- 发送
TYPE_SET_DISPLAY_POWER控制消息 - Server 通过反射调用
SurfaceControl.setDisplayPowerMode()实现屏幕控制
快速开始
1. 连接设备
USB 连接:
adb devices
网络连接:
adb connect <设备IP>:5555
2. 安装工具
pip install asctl
3. 使用
asctl --off # 关闭屏幕
asctl --on # 打开屏幕
系统要求
- Python 3.6+
- Android 设备(需要 USB 调试)
- ADB 工具
注意事项
- 需要设备开启 USB 调试
- 需要设备连接到电脑(USB 或网络)
- 保持唤醒功能会修改系统设置
故障排除
ADB 命令执行失败
- 确认设备已连接:
adb devices - 确认 USB 调试已开启
- 尝试重新连接 ADB
Server 启动失败
- 检查设备存储空间
- 尝试手动推送 server:
adb push asctl/data/scrcpy-server.jar /data/local/tmp/
屏幕控制无效
- 确认设备未锁屏
- 检查设备权限设置
- 查看详细日志:在代码中设置
log_level=debug
许可证
MIT License
参考
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
asctl-0.1.0.tar.gz
(100.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
asctl-0.1.0-py3-none-any.whl
(98.5 kB
view details)
File details
Details for the file asctl-0.1.0.tar.gz.
File metadata
- Download URL: asctl-0.1.0.tar.gz
- Upload date:
- Size: 100.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f59df4a0f0e2a2695691e483fdda9bd3a07f0759b52088915fcd521171e6a497
|
|
| MD5 |
5811a459054886f91d0be0dd0584193d
|
|
| BLAKE2b-256 |
00d9850c0a0ac44033a677029eaf01af0ffa79c6d7056190a2d6cc3db72ec162
|
File details
Details for the file asctl-0.1.0-py3-none-any.whl.
File metadata
- Download URL: asctl-0.1.0-py3-none-any.whl
- Upload date:
- Size: 98.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8575d57f83cdcdbd63d1ce103bd5fe3d6cd660b085e49ace9d32803e09ae7d72
|
|
| MD5 |
f825efc8adccec8ddcd032526551da43
|
|
| BLAKE2b-256 |
f4c439aa4ee2c01b754f17aeea2d0f312b14995e49c128576f8e3a238b5ce66d
|