【问题标题】:adb shell check if screen is on windows cmdadb shell 检查屏幕是否在 Windows cmd 上
【发布时间】:2022-08-14 11:17:03
【问题描述】:

我想创建 bat 脚本来打开屏幕。 这个命令adb shell dumpsys input_method | find \"mWakefulness=\" 是返回给我的结果

mWakefulness=Asleep
mWakefulness=Awake

我想检查 adb 是否返回 Asleep 结果,如果不是,我将打开它,例如

cd /d \"C:\\Program Files (x86)\\Remote\\adb\"
SET CHECK=\"adb shell dumpsys input_method | find \"mWakefulness=\"\"
if %CHECK% == \"mWakefulness=Asleep\" (
    adb shell input keyevent 26
) 

但看起来我走错了路,找不到如何做到这一点,我在 Windows 和他们的 cmd 中表现不佳。

    标签: android windows cmd adb


    【解决方案1】:

    找到解决方案

    @echo off
    cd /d "C:\Program Files (x86)\Remote\adb"
    
    
    setlocal
    for /f "delims= tokens=1*" %%a in ('adb shell dumpsys power ^| findstr.exe "mWakefulness=Asleep"') DO (
    for /f "delims== tokens=2*" %%S in ("%%a") do (
    if "%%S" == "false" (goto move1) else (goto move2)
    )
    )
    
    :move1
    goto end
    
    :move2
    start /MIN cmd /c adb shell input keyevent 26
    goto end
    
    :end
    exit
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-06
      • 2020-05-02
      相关资源
      最近更新 更多