我的需求是通过双击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