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
参考
Metadata
Release files for asctl 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| asctl-0.1.0.tar.gz | 100.7 kB | Without provenance | Details for asctl-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| asctl-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for asctl-0.1.0-py3-none-any.whl |
Total release size: 199.2 kB
Release files / asctl-0.1.0.tar.gz
| Download URL | asctl-0.1.0.tar.gz |
|---|---|
| Size | 100.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f59df4a0f0e2a2695691e483fdda9bd3a07f0759b52088915fcd521171e6a497
|
|
BLAKE2b-256 checksum How to use checksums |
00d9850c0a0ac44033a677029eaf01af0ffa79c6d7056190a2d6cc3db72ec162
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / asctl-0.1.0-py3-none-any.whl
| Download URL | asctl-0.1.0-py3-none-any.whl |
|---|---|
| Size | 98.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8575d57f83cdcdbd63d1ce103bd5fe3d6cd660b085e49ace9d32803e09ae7d72
|
|
BLAKE2b-256 checksum How to use checksums |
f4c439aa4ee2c01b754f17aeea2d0f312b14995e49c128576f8e3a238b5ce66d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Security for asctl 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.