Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to send custom adb commands through your server? #2248

Open
unofficialdev opened this issue Apr 12, 2021 · 3 comments
Open

How to send custom adb commands through your server? #2248

unofficialdev opened this issue Apr 12, 2021 · 3 comments

Comments

@unofficialdev
Copy link

unofficialdev commented Apr 12, 2021

Hello developers, I am new to scrcpy, this is a great application because of the speed of its communication with android devices. I am using c # to automate android.
I am wanting to go through a scrcpy server to improve the speed of sending custom commands to an android device. I finished starting up the scrcpy server from the c# code associated with the SharpAdbClient library.

My problem is not knowing how to send custom adb commands. For example: uiautomator dump/dev/tty and get the device's xml layout. or send touch commands, swipe in custom position. or adb command to take individual screenshots (only 1 image at a time) ...
Is there any example code or documentation to do the above? any example code or documentation is appreciated. Thanks a lot.

@unofficialdev
Copy link
Author

@rom1v Can you help me?

@rom1v
Copy link
Collaborator

rom1v commented Apr 13, 2021

More details here: #231 (comment)

Basically, scrcpy does not receive adb commands, but custom commands, which are reimplemented in java (using reflection to access Android framework).

More documentation:

@teonsen
Copy link

teonsen commented Mar 19, 2022

It is possible to send adb command to get the ui dump while scrcpy is running.

  1. Run open_a_terminal_here.bat to open an another command prompt. (inorder to use same adb.exe as scrcpy)
  2. Type any adb command to do whatever you want.
  • Get the ui dump.

adb exec-out uiautomator dump && adb pull /sdcard/window_dump.xml && adb shell rm /sdcard/window_dump.xml

  • Take a screen shot

adb shell screencap -p /sdcard/capture.png && adb pull /sdcard/capture.png && adb shell rm /sdcard/capture.png

It worked on my Android 9 environment.
@rom1v Thank you very much for sherering such a wonderful tool by the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants