最近重新需要使用scrcpy进行投屏到电脑上操作手机,但是打字的时候只能输入数字和英文,通过查询(关于scrcpy对中文输入法支持不友好的解决办法 · Issue #1055 · Genymobile/scrcpy (github.com))知道qq输入法支持输入中文,但是又习惯用搜狗输入法了,经过链接里面有位老哥的思路提示,
我的需求是通过双击scrcpy-noconsole.vbs开启scrcpy后自动启用qq输入法,关闭scrcpy后启动搜狗输入法,方法如下:
(1) adb shell ime list -a查看当前手机安装的所有输入法的包名,复制想要切换的包名。
(2)adb shell ime set +输入法包名 命令可切换输入法。scrcpy-noconsole.vbs改为通过scrcpy-console.bat启动scrcpy,scrcpy-console.bat文件增加两条设换输入法的命令,两个文件内容具体如下:
scrcpy-console.bat文件:
- @echo off
- adb shell ime set com.tencent.qqpinyin/.QQPYInputMethodService @rem 启动scrcpy前设置qq输入法
- scrcpy.exe %*
- :: if the exit code is >= 1, then pause
- adb shell ime set com.sohu.inputmethod.sogou/.SogouIME @rem 退出scrcpy后设置搜狗输入法
- if errorlevel 1 pause
- adb shell ime set com.sohu.inputmethod.sogou/.SogouIME @rem 退出scrcpy后设置搜狗输入法
scrcpy-noconsole.vbs文件:
- strCommand = "cmd /c scrcpy-console.bat"
-
- For Each Arg In WScript.Arguments
- strCommand = strCommand & " """ & replace(Arg, """", """""""""") & """"
- Next
-
- CreateObject("Wscript.Shell").Run strCommand, 0, false