mattwilson1024 / android-pattern-unlock Goto Github PK
View Code? Open in Web Editor NEWUtility script to automate the swiping of a lockscreen pattern on an Android device via ADB.
Utility script to automate the swiping of a lockscreen pattern on an Android device via ADB.
When i run this script ,there are some mistakes:
.....
: command not found
'nlock.sh: line 79: syntax error near unexpected token { 'nlock.sh: line 79:
WakeScreen(){
How can i run this script successful?
Hello,
i can't manage to unlock pattern on my samsung a07s, i think it's adb that can't find device attached.
log:
./unlock.sh
./unlock.sh: 57: X[1]=332: not found
./unlock.sh: 58: X[2]=768: not found
./unlock.sh: 59: X[3]=1152: not found
./unlock.sh: 60: X[4]=332: not found
./unlock.sh: 61: X[5]=768: not found
./unlock.sh: 62: X[6]=1152: not found
./unlock.sh: 63: X[7]=332: not found
./unlock.sh: 64: X[8]=768: not found
./unlock.sh: 65: X[9]=1152: not found
./unlock.sh: 67: Y[1]=1106: not found
./unlock.sh: 68: Y[2]=1106: not found
./unlock.sh: 69: Y[3]=1106: not found
./unlock.sh: 70: Y[4]=1476: not found
./unlock.sh: 71: Y[5]=1476: not found
./unlock.sh: 72: Y[6]=1476: not found
./unlock.sh: 73: Y[7]=1968: not found
./unlock.sh: 74: Y[8]=1968: not found
./unlock.sh: 75: Y[9]=1968: not found
* daemon not running; starting now at tcp:5037
* daemon started successfully
error: no devices/emulators found
error: no devices/emulators found
error: no devices/emulators found
./unlock.sh: 110: Bad substitution
Hi Matt,
I'm trying to get your script to run. But no matter where I call it from (adb on pc, android terminal) always gives me error: syntax error: 'WakeScreen
I have tried to see why but failed. I have a background in PHP so I understand logic and function syntax but I have no experience with shell script. I'm running your script on Nexus 2013 running Android 6 rooted and with ElementalX kernel.
Any help would be appreciated.
Initially it unlocks the device and swipe up, but when it comes to co-ordinates, it is sending too, but it does nothing to the device.. Please find the logs.
$ bash test.sh
Sending 1: 254, 948
Sending 4: 254, 1224
Sending 7: 254, 1526
Sending 8: 513, 1526
Trying to draw L through it.. 1,4,7,8..
Here is my pattern. Please check.
PATTERN="1 4 7 8" # The unlock pattern to draw, space seperated
COL_1=254 # X coordinate of column 1 (in pixels)
COL_2=513 # X coordinate of column 2 (in pixels)
COL_3=818 # X coordinate of column 3 (in pixels)
ROW_1=948 # Y coordinate of row 1 (in pixels)
ROW_2=1224 # Y coordinate of row 2 (in pixels)
ROW_3=1526 # Y coordinate of row 3 (in pixels)
MULTIPLIER=1 # Multiplication factor for coordinates. For Nexus 4, set this to 2. For low res phones such as
# Samsung Galaxy S2, set this to 1. Experiment with this value if you can't see anything happening.
WAKE_SCREEN_ENABLED=true # If true, the script will start by sending the power button press event
SWIPE_UP_ENABLED=true # If true, the script will swipe upwards before drawing the pattern (e.g. for lollipop lockscreen)
SWIPE_UP_X=450 # X coordinate for initial upward swipe. Only used if SWIPE_UP_ENABLED is true
SWIPE_UP_Y_FROM=1000 # Start Y coordinate for initial upward swipe. Only used if SWIPE_UP_ENABLED is true
SWIPE_UP_Y_TO=200 # End Y coordinate for initial upward swipe. Only used if SWIPE_UP_ENABLED is true
# =======================================================================================================================
# Define X&Y coordinates for each of the 9 positions.
X[1]=$(( ${COL_1} * ${MULTIPLIER} ))
X[2]=$(( ${COL_2} * ${MULTIPLIER} ))
X[3]=$(( ${COL_3} * ${MULTIPLIER} ))
X[4]=$(( ${COL_1} * ${MULTIPLIER} ))
X[5]=$(( ${COL_2} * ${MULTIPLIER} ))
X[6]=$(( ${COL_3} * ${MULTIPLIER} ))
X[7]=$(( ${COL_1} * ${MULTIPLIER} ))
X[8]=$(( ${COL_2} * ${MULTIPLIER} ))
X[9]=$(( ${COL_3} * ${MULTIPLIER} ))
Y[1]=$(( ${ROW_1} * ${MULTIPLIER} ))
Y[2]=$(( ${ROW_1} * ${MULTIPLIER} ))
Y[3]=$(( ${ROW_1} * ${MULTIPLIER} ))
Y[4]=$(( ${ROW_2} * ${MULTIPLIER} ))
Y[5]=$(( ${ROW_2} * ${MULTIPLIER} ))
Y[6]=$(( ${ROW_2} * ${MULTIPLIER} ))
Y[7]=$(( ${ROW_3} * ${MULTIPLIER} ))
Y[8]=$(( ${ROW_3} * ${MULTIPLIER} ))
Y[9]=$(( ${ROW_3} * ${MULTIPLIER} ))
# Function definitions
WakeScreen() {
if [ "$WAKE_SCREEN_ENABLED" = true ]; then
adb shell input keyevent 26
fi
}
SwipeUp() {
if [ "$SWIPE_UP_ENABLED" = true ]; then
adb shell input swipe ${SWIPE_UP_X} ${SWIPE_UP_Y_FROM} ${SWIPE_UP_X} ${SWIPE_UP_Y_TO}
fi
}
StartTouch() {
adb shell sendevent /dev/input/event1 3 57 14
}
SendCoordinates () {
adb shell sendevent /dev/input/event1 3 53 $1
adb shell sendevent /dev/input/event1 3 54 $2
adb shell sendevent /dev/input/event1 3 58 57
adb shell sendevent /dev/input/event1 0 0 0
}
FinishTouch() {
adb shell sendevent /dev/input/event1 3 57 4294967295
adb shell sendevent /dev/input/event1 0 0 0
}
SwipePattern() {
for NUM in $PATTERN
do
echo "Sending $NUM: ${X[$NUM]}, ${Y[$NUM]}"
SendCoordinates ${X[$NUM]} ${Y[$NUM]}
done
}
# Actions
WakeScreen
SwipeUp
StartTouch
SwipePattern
FinishTouch
http://stackoverflow.com/questions/37923618/is-there-any-android-automation-robot
I want to create a script that will:
Do u think it is possible to achieve this using only adb?
is there any better tool to handle this? without need to know the specific pixels positions?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.