I have a Batch file that executes a code for every hour for 24 hours but I noticed that sometimes the timeout 3600 line of code will freeze until the user hit any button, is there a way to avoid this? The code basically turns on and off Airplane mode atop of every hour then screenshots data usage for the past hour. Please see below for code. Let me know if you have a better way to run this code other than Batch :)
set /a index = 0
::Unlock PDM
adb shell input keyevent 82
timeout 1
adb shell input keyevent 82
adb shell input text 1111
timeout 1
::Screenshot data usage
adb shell am start -a android.settings.DATA_USAGE_SETTINGS
timeout 1
adb shell input tap 550 1500
timeout 4
adb shell input swipe 600 2050 600 1900
timeout 1
adb shell screencap -p /sdcard/%index%_a1.png
timeout 1
:While
if %index% leq 21 (
::APM On
echo.
echo Enabling APM
::Launch APM Settings
adb shell am start -a android.settings.AIRPLANE_MODE_SETTINGS
timeout 1
::Toggle On
adb shell input tap 825 325
timeout 1
::Navigate to Op5
adb shell am start com.insulet.myblue.pdm
timeout 1
::Turn BLE On
adb shell input tap 550 1600
echo check 2
timeout 2
::Screenshot data usage
adb shell am start -a android.settings.DATA_USAGE_SETTINGS
timeout 4
adb shell screencap -p /sdcard/%index%_a2.png
timeout 1
::Navigate to Op5
adb shell am start com.insulet.myblue.pdm
::Timeout for 60 min
timeout 3600 /nobreak
::Unlock PDM
adb shell input keyevent 82
timeout 1
adb shell input keyevent 82
adb shell input text 1111
timeout 1
echo check 4
timeout 2
::APM Off
echo.
echo Disabling APM
::Launch APM Settings
adb shell am start -a android.settings.AIRPLANE_MODE_SETTINGS
timeout 1
::Toggle Off
adb shell input tap 825 325
timeout 1
::Navigate to Op5
adb shell am start com.insulet.myblue.pd
echo check 5
timeout 2
::Timeout for 10 min
timeout 600 /nobreak
::Unlock PDM
adb shell input keyevent 82
timeout 1
adb shell input keyevent 82
adb shell input text 1111
timeout 1
echo check 6
timeout 2
::Screenshot data usage
adb shell am start -a android.settings.DATA_USAGE_SETTINGS
timeout 4
adb shell screencap -p /sdcard/%index%_b1.png
timeout 1
echo check 7
::Navigate to Op5
adb shell am start com.insulet.myblue.pdm
echo check 8
timeout 2
set /a "index = index + 1"
echo # of runs: %index%
echo.
echo.
echo.
echo.
echo ENDDDD**************************************
goto :while
)