-
-
Save Isanderthul/e6a1958f060ac86045cc03396fec9326 to your computer and use it in GitHub Desktop.
Send an sms from a computer through an Android device using ADB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# Send text through adb by Madura A. | |
# https://market.android.com/details?id=org.jraf.android.nolock | |
# Please use the above app(or similar) to keep it from locking while | |
# using this script | |
# If screen is off, turn it on and unlock it (Only works with slide to unlock) | |
if adb shell dumpsys input_method | grep -q mScreenOn=false; then | |
$ADB shell input keyevent 26 | |
$ADB shell input swipe 250 650 1000 650 | |
sleep 1 | |
fi | |
# Check if sms app is already running and close it if it is | |
test=$($ADB shell ps | grep com.android.mms | awk '{print $9}'); | |
if [ ! -z $test ]; then | |
$ADB shell am force-stop com.android.mms | |
fi | |
# Launch an intent to send an sms with the number and text passed in parameters | |
adb shell am start -a android.intent.action.SENDTO -d sms:$1 --es sms_body "$2" --ez exit_on_sent true | |
sleep 1 | |
# Press send button | |
adb shell input keyevent 22 | |
sleep 1 | |
adb shell input keyevent 66 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment