我使用 adb shell 命令检查我的设备的屏幕是否打开
adb shell dumpsys power | find "mWakefulness="
如果屏幕关闭此命令返回mWakefulness=Asleep
我想要做的是将该命令的输出分配给一个变量并通过 if 语句运行它以检查是否mWakefulness=Asleep
我试过这个
@echo off
for /f "delims=" %%a in ('adb shell dumpsys power | find "mWakefulness="') do (
Set "Output=%%a"
)
Echo Output Result = "%OutPut%"
但这会返回| was unexpected at this time.
所以我试着adb shell dumpsys power | find "mWakefulness="
用双引号括起来
@echo off
for /f "delims=" %%a in ('"adb shell dumpsys power | find "mWakefulness=""') do (
Set "Output=%%a"
)
Echo Output Result = "%OutPut%"
但这会返回Output Result = ""
谁能帮忙?