CMD之for 获取当前运行的APP name是否是指定APP
可以将“OPCameraActivity”换成自己的APP名字
@echo off
set activity=
for /f "tokens=1 delims=/" %%i in ('adb shell dumpsys window w ^|grep \/ ^|grep name=^|grep OPCameraActivity') do ( set activity=%%i)
for /f "tokens=1 delims=)" %%i in ( "%activity%" ) do ( set activity=%%i)
for /f "tokens=2 delims=(" %%i in ( "%activity%" ) do ( set activity=%%i)
for /f "tokens=2 delims==" %%i in ( "%activity%" ) do ( set activity=%%i)
echo "current activity %activity%"