scrcpy-将Android手机屏幕实时投射到电脑

scrcpy是一款实用工具,能够实现在电脑上实时投射Android手机屏幕。通过USB连接手机并开启USB调试,可以快速投射屏幕。支持多个设备同时连接,并提供了丰富的快捷键功能,如Ctrl+b模拟返回键,Ctrl+h模拟主页键等。当遇到鼠标、键盘无效的问题时,可能需要在手机开发者选项中启用“USB调试(安全设置)”。此外,还介绍了依赖包安装和scrcpy服务器的编译过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

scrcpy 将 Android 手机屏幕实时投射到电脑

从软件库安装

Linux

# ubuntu
apt install scrcpy

# arch aur
yay -S scrcpy

使用

  1. 连上手机(打开“usb调试”)
  2. 电脑运行 scrcpy,GUI启动,立即投射当前手机屏幕

多个手机同时连接

$ adb devices
List of devices attached
26b98700	device
c676c6b3	device

# 连接第1个手机
$ scrcpy -s 26b98700

# 连接第2个手机
$ scrcpy -s c676c6b3

scrcpy -h 查看帮助。

拖动安装apk

从电脑拖动apk,就可以将apk安装到设备。

快捷键

Ctrl + b | back键
Ctrl + h | home键
Ctrl + s | app switch
Ctrl + m | menu键
Ctrl + Up | 音量上
Ctrl + Down | 音量下
Ctrl + p | 关机键(turn screen on/off)
Right-click | power on(when screen is off)
Ctrl+o | turn device screen off (keep mirroring)
Ctrl+n | expand notification panel
Ctrl+Shift+n| collapse notification panel
Ctrl+c | copy device clipboard to computer
Ctrl+v | paste computer clipboard to device
Ctrl+i | enable/disable FPS counter (print frames/second in logs)

trouble shootingcategories: [cm, android]

tags: [scrcpy, mint]

鼠标、键盘无效

可能需要在手机中设置: Developer options -> 勾选 “USB debugging(Security settings)”

参考: https://github.com/Genymobile/scrcpy/issues/70#issuecomment-373286323

依赖包安装

# runtime dependencies
sudo apt install ffmpeg libsdl2-2.0-0

# client build dependencies
sudo apt install make gcc git pkg-config meson ninja-build \
                 libavcodec-dev libavformat-dev libavutil-dev \
                 libsdl2-dev

# server build dependencies
sudo apt install openjdk-8-jdk

On old versions (like Ubuntu 16.04), meson is too old. In that case, install it from pip3:

sudo apt install python3-pip

# 解决 ModuleNotFoundError: No module named 'setuptools' 报错
pip3 install --upgrade setuptools

# 解决 error: invalid command 'bdist_wheel' 报错
pip3 install --upgrade wheel

pip3 install --upgrade meson

# meson 的安装位置 /home/wi/.local/bin/meson

编译 scrcpy 服务器(电脑端)

export ANDROID_HOME=~/android/sdk

git clone https://github.com/Genymobile/scrcpy
cd scrcpy

# then, build
# Note: ninja must be run as a non-root user (only ninja install must be run as root).
meson x --buildtype release --strip -Db_lto=true
cd x
# 因为GFW,可能会编译失败,可以通过proxy联网: proxychains ninja
ninja

# 安装
sudo ninja install    # without sudo on Windows

This installs two files:

  • /usr/local/bin/scrcpy
  • /usr/local/share/scrcpy/scrcpy-server.jar

卸载

sudo ninja uninstall
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值