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 can I get scrcpy to open automatically as I connect phone to usb? Also screen off upon exit and allow access to phone data on the phone upon connection.. #2103

Open
ceyhun242 opened this issue Feb 9, 2021 · 12 comments

Comments

@ceyhun242
Copy link

3 questions:

Is there a way for the phone to automatically run the scrcpy shortcut on the taskbar as soon as I plug USB to the phone?

How can I always allow the prompt on android screen to access the phone data when I plug the phone to computer?

How can I force screen not to turn on when I unplug the phone from computer or close the scrcpy app?

Thank you

@rom1v
Copy link
Collaborator

rom1v commented Feb 9, 2021

Is there a way for the phone to automatically run the scrcpy shortcut on the taskbar as soon as I plug USB to the phone?

https://github.com/Genymobile/scrcpy#autostart-on-device-connection

How can I always allow the prompt on android screen to access the phone data when I plug the phone to computer?

If you talk about the USB debugging popup, just check "Always accept" (or similar). If you talk about the "MTP/PTP" dialog, I don't know.

How can I force screen not to turn on when I unplug the phone from computer or close the scrcpy app?

When you unplug the device, it leaves the screen as is.

If you pass --turn-screen-off (or press MOD+o during mirroring), then the device screen is ON but "physically" OFF. In that case, it will switch back to "physically" ON on close (but still leave the screen state as it was). Refs #1764.

@ceyhun242
Copy link
Author

I use --turn-screen-off on shortcut and it turns screen off. Upon exiting the app to unplugging the phone switches screen to ON. Id like screen to stay as is (which is initially off by --turn-screen-off) upon both exiting the pap and unplugging but now it defaults screen to ON. how can I make screen always stay off?

where do I place this command on shortcut?
"autoadb scrcpy -s '{}'"

the prompt is ""Allow access to phone data? the connected device will be able to access data on this phone." Its samsung S7 android 8 version. there is no "always accept" how can I have this always accept?

@rom1v
Copy link
Collaborator

rom1v commented Feb 9, 2021

I use --turn-screen-off on shortcut and it turns screen off. Upon exiting the app to unplugging the phone switches screen to ON. Id like screen to stay as is (which is initially off by --turn-screen-off) upon both exiting the pap and unplugging but now it defaults screen to ON.

If you use --turn-screen-off, and wait for the device display to be off also in the scrcpy window (after timeout, or by pressing MOD+p), and then unplug, does it turn the device screen on?

@ceyhun242
Copy link
Author

ceyhun242 commented Feb 9, 2021

I use --turn-screen-off on shortcut and it turns screen off. Upon exiting the app to unplugging the phone switches screen to ON. Id like screen to stay as is (which is initially off by --turn-screen-off) upon both exiting the pap and unplugging but now it defaults screen to ON.

If you use --turn-screen-off, and wait for the device display to be off also in the scrcpy window (after timeout), and then unplug, does it turn the device screen on?

I just tested, exactly as you said, it still turns the device screen on

I managed to disable prompt, it was thanks to installing samsung USB driver for mobile phones.. now there is no prompt upon plugging USB

where do I place this command on shortcut?
"autoadb scrcpy -s '{}'"

Where will I place the --legacy-paste within the shortcut?

How can I take screenshot with scrcpy?

@rom1v
Copy link
Collaborator

rom1v commented Feb 9, 2021

I just tested, exactly as you said, it still turns the device screen on

Oh, on my device, USB-unplugging the device turns it on, scrcpy or not.
However, just closing scrcpy does not.

where do I place this command on shortcut?
"autoadb scrcpy -s '{}'"

Where will I place the --legacy-paste within the shortcut?

Sorry, I don't really know how Windows shortcuts work.
But just place your commands in a .bat file: https://github.com/Genymobile/scrcpy/blob/master/FAQ.md#command-line-on-windows

How can I take screenshot with scrcpy?

Currently, it's not possible (you can only record a video scrcpy --record file.mkv). See #684

@ceyhun242
Copy link
Author

Could you please tell me what I need to write within vbs or bat file for all these to be applied together?

  • turn off screen
  • legacy paste
  • auto start with USB?

how could these be applied to shortcut? If I place this on target section of the shortcut (it has to be shortcut for .exe file, then it turns screen off, but if I add legacy and adb autostart the shortcut doesn't run the app. how could I make this work?
"D:.....\scrcpy-win64-v1.16\scrcpy-noconsole.exe" --turn-screen-off

Also how can I create exe file for 1.17 version? there is only scrcpy.exe. Id like to have as before scrcpy-noconsole.exe and preferably an exe along with all these features above Id like to add. How can that be done?

note: I just checked, yes closing app doesn't turn on screen. How can I have the screen not go off when unplugging USB?

Thank you

@JohnnyRico140
Copy link

When I execute autoadb scrcpy -s '{} on the same folder with scrcpy.exe, adb.exe and autoadb.exe inside, I have this error message :

Deteted device mveuq4twkjg6pn8x
scrcpy 1.21 https://github.com/Genymobile/scrcpy
adb: error: failed to get feature set: device ''{}'' not found
ERROR: "adb push" returned with value 1
ERROR: Server connection failed

I have no problem running scrcpy manually besides that...

Thanks for any help !

@rom1v
Copy link
Collaborator

rom1v commented Jan 4, 2022

Do not add quotes (command-line parsing on Windows is weird):

autoadb scrcpy -s {}

@JohnnyRico140
Copy link

JohnnyRico140 commented Jan 4, 2022

Do not add quotes:

scrcpy -s {}

Wow, it was so simple, thanks for the quick reply ! Merci ! (pour ça et scrcpy, j'en profite !)

@DrSaad77
Copy link

Hello, I am too looking into "autostart-on-device-connection" of Scrcpy, unfortunatly without success. That is the error, I get when running scrcpy -s {}
Any help please, or I did not understand exactly how to use "scrcpy -s {}".
Capture d’écran 2024-03-23 232927

Thx

@rom1v
Copy link
Collaborator

rom1v commented Mar 23, 2024

It's autoadb scrcpy -s {}.

See https://github.com/rom1v/autoadb

@DrSaad77
Copy link

DrSaad77 commented Mar 24, 2024

Thx you very much for the new link for autoadb, cause the one upper, goes to the main Scrcpy page...
I followed the step in this comment, and it is working.
rom1v/autoadb#21 (comment)
Just had a bit issue, for "autoadb" to start on PC boot, but now it is fine.
Thx ;)

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

4 participants