Luke
Luke

Reputation: 781

Tell Smartphone to send SMS with PC

Is there a way to do the following instructions using Android on phone and Windows on computer?

  1. Computer: Reads numbers and meeting-dates out of a database.

  2. Computer: Connects to the smartphone (via USB?) and uses its "send SMS"-function

  3. Smartphone: Sends SMS with given Text.


Or do i have to use Third Party Email to SMS tools? I'd like to avoid that.

Upvotes: 0

Views: 2139

Answers (1)

CherryDT
CherryDT

Reputation: 29011

You can use USB debugging and some faked user input.

First, enable USB debugging. Depending on your Android version and device model, this may be either an option somewhere in the normal settings app or in the hidden developer mode which you can access by tapping the build number under "Status" 7 times. Also, you may be asked to allow access from your computer the first time you try to do anything with this feature.

Then, download ADB and any driver needed for your device, if any. ADB is a command-line tool to send debugging commands to your device.

You can use adb devices in the console to see if things work - you should see your device listed.

The idea is now to start the SMS app with recipient and text already filled in (which is a supported action) and then fake the user clicking "Send". This is where the tricky part lies. Depending on your device, there can be different key input required than for mine, for example. Usually you will need to send one or more D-Pad presses plus "Enter" (yes this works even if the device doesn't have a D-Pad).

The commands you'll need:

  • adb shell am start -a android.intent.action.SENDTO -d sms:<full phone number here> --es sms_body "<SMS text here>" --ez exit_on_sent true
    This will open the SMS app with the values already filled in. Replace <full phone number here> with the phone number, and <SMS text here> with your text. If you need to use quotes inside the text, you have to escape them like \".
  • adb shell input keyevent <id>
    This will send a fake keypress. The possible IDs are listed here. Particularly interesting are:
    19: D-Pad up
    20: D-Pad down
    21: D-Pad left
    22: D-Pad right
    23: D-Pad center
    66: Enter
    You will need to play with these. You probably need to send 22 or 20 to simulate a "right" or "down" press to focus the "Send" button followed by 23 or 66 to simulate a press on the D-Pad center or enter key to "click" the button.

So, for example, it could look like this:

adb shell am start -a android.intent.action.SENDTO -d sms:+436501234567 --es sms_body "This is a test" --ez exit_on_sent true
adb shell input keyevent 20
adb shell input keyevent 66

This would open the SMS app with the number +436501234567 and the text This is a test already filled in and then simulate the "down" key and the "enter" key.

Please give the whole thing some time. Add some delays (at least 1s) between each command.

Upvotes: 3

Related Questions