-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsendadb.py
More file actions
21 lines (16 loc) · 806 Bytes
/
sendadb.py
File metadata and controls
21 lines (16 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import subprocess
while True:
# Get the message from user input
message = input("Enter the message you want to send (or enter 'q' to quit): ")
if message == 'q':
break
# Construct the ADB command to send the message
adb_command = ['adb', 'shell', 'input', 'text', '"{}"'.format(message)]
# Execute the ADB command to send the message
process = subprocess.Popen(adb_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
output, error = process.communicate(input='1\n') # Send '1' as input followed by Enter ('\n')
# Check if the command was successful
if process.returncode == 0:
print("Message successfully sent using ADB")
else:
print("An error occurred while sending the message:", error.decode('utf-8'))