From b7308d0e21e44fb7026408a42708f810b8503dca Mon Sep 17 00:00:00 2001 From: Someone Date: Sun, 18 Dec 2016 20:30:23 +0100 Subject: [PATCH] ingress autorecharger. --- ingress_auto_recharge.sh | 123 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100755 ingress_auto_recharge.sh diff --git a/ingress_auto_recharge.sh b/ingress_auto_recharge.sh new file mode 100755 index 0000000..f4ecc52 --- /dev/null +++ b/ingress_auto_recharge.sh @@ -0,0 +1,123 @@ +#!/bin/zsh + +# recharges keys. +## moves neutral or enemy to first capsule +## eats cubes +# + +RECHARGER_KEYCOUNT=$1 +RECHARGER_RECHARGECOUNT=50 +INGRESS_SCREENSHOT_FILENAME="/tmp/ingress_auto_recharge.png" + +# expectation: inventory is in "key" mode, first/starting key visible. +# open inventory, position first. +#~/Android/Sdk/platform-tools/adb shell input touchscreen tap 51 1580 # click item slider left +#~/Android/Sdk/platform-tools/adb shell input touchscreen swipe 550 900 750 900 100 # swipe right -> select first +#sleep 1 + +# repeat for all keys +for key in `seq 1 1 $RECHARGER_KEYCOUNT` ; do + echo -n "key:$key ($(date -Isec)) -- " + + # recharge run + for rr in `seq 1 1 $RECHARGER_RECHARGECOUNT` ; do + rr=$(printf "%02d" $rr) + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 550 900 # click on key + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 200 1840 # click "recharge" -> open recharge screen + + sleep 0.3 + + ~/Android/Sdk/platform-tools/adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > $INGRESS_SCREENSHOT_FILENAME + xm0="$(convert png:$INGRESS_SCREENSHOT_FILENAME -crop '1x1+204+130' txt:- | awk 'NR==2{print}' | cut -d, -f4)" + xm1="$(convert png:$INGRESS_SCREENSHOT_FILENAME -crop '1x1+404+130' txt:- | awk 'NR==2{print}' | cut -d, -f4)" + xm2="$(convert png:$INGRESS_SCREENSHOT_FILENAME -crop '1x1+604+130' txt:- | awk 'NR==2{print}' | cut -d, -f4)" + xm3="$(convert png:$INGRESS_SCREENSHOT_FILENAME -crop '1x1+804+130' txt:- | awk 'NR==2{print}' | cut -d, -f4)" + + faction="$(convert png:$INGRESS_SCREENSHOT_FILENAME -crop '1x1+36+620' txt:- | awk 'NR==2{print}' | cut -d, -f4)" + + rm "$INGRESS_SCREENSHOT_FILENAME" + + #echo -n "rr:$rr sc:$xm0.$xm1.$xm2.$xm3 fac:$faction -- " + + if [[ $xm0 != "90" ]] && [[ $faction == "214" ]]; then + echo "evil." + # move key to first capsule. + ~/Android/Sdk/platform-tools/adb shell input keyevent KEYCODE_BACK # unclick key + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 300 1700 # click on category slider in inventory + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 300 1025 # click on "capsules" (assuming "portal keys" is selected) + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 51 1580 # click item slider left + ~/Android/Sdk/platform-tools/adb shell input touchscreen swipe 550 900 750 900 100 # swipe right -> select first + sleep 1 + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 550 900 # click on capsule + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 200 1640 # click "load" + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 550 900 # mark key + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 550 1800 # click "transfer" + ~/Android/Sdk/platform-tools/adb shell input keyevent KEYCODE_BACK # close capsule + ~/Android/Sdk/platform-tools/adb shell input keyevent KEYCODE_BACK # unclick capsule + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 300 1700 # click on category slider in inventory + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 300 1220 # click on "portal keys" (assuming "capsules" is selected) + export INGRESS_NO_NEXT_ITEM_SWIPE="true" + break + fi + if [[ $xm0 != "90" ]] && [[ $faction != "214" ]] && [[ $faction != "33" ]]; then + echo "neut." + # move key to first capsule. + ~/Android/Sdk/platform-tools/adb shell input keyevent KEYCODE_BACK # unclick key + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 300 1700 # click on category slider in inventory + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 300 1025 # click on "capsules" (assuming "portal keys" is selected) + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 51 1580 # click item slider left + ~/Android/Sdk/platform-tools/adb shell input touchscreen swipe 550 900 750 900 100 # swipe right -> select first + sleep 1 + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 550 900 # click on capsule + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 200 1640 # click "load" + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 550 900 # mark key + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 550 1800 # click "transfer" + ~/Android/Sdk/platform-tools/adb shell input keyevent KEYCODE_BACK # close capsule + ~/Android/Sdk/platform-tools/adb shell input keyevent KEYCODE_BACK # unclick capsule + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 300 1700 # click on category slider in inventory + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 300 1220 # click on "portal keys" (assuming "capsules" is selected) + export INGRESS_NO_NEXT_ITEM_SWIPE="true" + break + fi + + if [[ $xm0 == "0" ]] && [[ $xm1 == "0" ]] && [[ $xm2 == "0" ]] && [[ $xm3 == "0" ]]; then + #echo "not rechargable. skipping." + echo "full." + ~/Android/Sdk/platform-tools/adb shell input keyevent KEYCODE_BACK # unclick key + break + fi + + # check if need to eat cube + if [[ $xm0 == "90" ]] && [[ $xm1 != "90" ]] && [[ $xm2 != "90" ]] && [[ $xm3 != "90" ]]; then + #echo -n "eating powercube + " + echo -n "epc " + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 950 150 # click "ops" + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 300 1700 # click on category slider in inventory + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 300 1300 # click on "power cubes" (assuming "portal keys" is selected) + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 51 1580 # click item slider left + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 550 900 # click on cube + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 200 1840 # click "use" + + # restore previous position. + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 950 150 # click "ops" + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 300 1700 # click on category slider in inventory + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 300 1300 # click on "portal keys" (assuming "power cubes" is selected) + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 550 900 # click on key + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 200 1840 # click "recharge" -> open recharge screen + fi + + # finally recharge portal + #echo "recharging..." + echo -n "r$rr " + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 250 1700 # click "recharge all" + ~/Android/Sdk/platform-tools/adb shell input touchscreen tap 850 1700 # click "done" + ~/Android/Sdk/platform-tools/adb shell input keyevent KEYCODE_BACK # unclick key + done + + # move to next key + if [[ -z $INGRESS_NO_NEXT_ITEM_SWIPE ]] ; then + ~/Android/Sdk/platform-tools/adb shell input touchscreen swipe 840 900 350 900 1500 # swipe to next key + fi + unset INGRESS_NO_NEXT_ITEM_SWIPE +done + -- 2.43.0