You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When multiple devices are present, let the user pick one. #3137
I have checked that a similar feature request does not already exist.
Is your feature request related to a problem? Please describe. I'm always frustrated when I run scrcpy only to realize I had multiple devices/emulators connected and then need to copy the serial of one to connect to the device of my choice.
Describe the solution you'd like
Instead of yielding an error, output the list of devices with each device prefixed by a number and then have scrcpy await user input for which device to use:
> scrcpy
Multiple (3) ADB devices:
1) (usb) QZ125F6WA1 device XQ_BQ52
2) (usb) emulator-5554 device sdk_google_atv_x86
3) (usb) emulator-5555 device sdk_google_atv_x86
Which device would you like to use (0 to exit)? 2
The copy could perhaps be a bit better.
Describe alternatives you've considered
An alternate solution would perhaps be if I wrote my own script which wraps the scrcpy tool with logic based on the scrcpy output, but that could likely break at any time.
Instead of yielding an error, output the list of devices with each device prefixed by a number and then have scrcpy` await user input for which device to use:
I already considered that, but scrcpy could not rely on user input, the user may start it without a console (that's quite common). And even when a console is available, it may be started from a script which does not expect it to wait.
#3005 added -d and -e to select USB and TCP/IP devices. But contrary to adb, an emulator is considered as an USB device. This is a bug, I'll fix it in the next release.
In your specific case, that would allow to call scrcpy -d to select the real device.
Instead of yielding an error, output the list of devices with each device prefixed by a number and then have scrcpy await user input for which device to use:
I already considered that, but scrcpy could not rely on user input, the user may start it without a console (that's quite common). And even when a console is available, it may be started from a script which does not expect it to wait.
Thanks for taking the time to reply, and that you already had given it some thought :) Now that I understand better the reasons for not implementing a feature like this, feel free to close this.
I'm happy I discovered something else totally unintentionally 😅
Instead of yielding an error, output the list of devices with each device prefixed by a number and then have scrcpy` await user input for which device to use:
I already considered that, but scrcpy could not rely on user input, the user may start it without a console (that's quite common). And even when a console is available, it may be started from a script which does not expect it to wait.
What I've seen other libraries do in this case is that you pass an argument to the command, such as -i which would make it "interactable". So if you don't pass -i nothing is changed, it will throw an error just like before, but if you pass -i it will wait for user input if necessary.
Ran into this and figured out that you can use the -s number parameter to connect to a specific device via its serial number. With the error that pops up in this scenario, scrcpy shows a list of devices like in the post above, with the second column consisting of serial numbers. You can then run scrcpy -s QZ125F6WA1 to connect to the first device, or scrcpy -s emulator-5554 to the second.
This allows picking which device to connect to in a protocol-agnostic way, as far as i can tell, which means this issue has a solution. But I feel like the error message could be a little better.
The line Select a device via -s (--serial), -d (--select-usb) or -e (--select-tcpip) lead me to believe that in these 3 options, two of which are about connection method, --serial is the option for connecting via a serial port and has nothing to do with devices's serial numbers. Reading the man page helped, but it could be a little clearer that this is what that does I think.
Activity
rom1v commentedon Mar 22, 2022
I already considered that, but scrcpy could not rely on user input, the user may start it without a console (that's quite common). And even when a console is available, it may be started from a script which does not expect it to wait.
rom1v commentedon Mar 22, 2022
#3005 added
-dand-eto select USB and TCP/IP devices. But contrary toadb, an emulator is considered as an USB device. This is a bug, I'll fix it in the next release.In your specific case, that would allow to call
scrcpy -dto select the real device.Consider emulators to be TCP/IP devices
Consider emulators as TCP/IP devices
rom1v commentedon Mar 22, 2022
Fixed by #3140.
oscarb commentedon Mar 22, 2022
Thanks for taking the time to reply, and that you already had given it some thought :) Now that I understand better the reasons for not implementing a feature like this, feel free to close this.
I'm happy I discovered something else totally unintentionally 😅
0x2539 commentedon Jun 13, 2022
What I've seen other libraries do in this case is that you pass an argument to the command, such as
-iwhich would make it "interactable". So if you don't pass-inothing is changed, it will throw an error just like before, but if you pass-iit will wait for user input if necessary.Update scrcpy-console.bat
Architector4 commentedon Feb 11, 2025
Ran into this and figured out that you can use the
-s numberparameter to connect to a specific device via its serial number. With the error that pops up in this scenario, scrcpy shows a list of devices like in the post above, with the second column consisting of serial numbers. You can then runscrcpy -s QZ125F6WA1to connect to the first device, orscrcpy -s emulator-5554to the second.This allows picking which device to connect to in a protocol-agnostic way, as far as i can tell, which means this issue has a solution. But I feel like the error message could be a little better.
The line
Select a device via -s (--serial), -d (--select-usb) or -e (--select-tcpip)lead me to believe that in these 3 options, two of which are about connection method,--serialis the option for connecting via a serial port and has nothing to do with devices's serial numbers. Reading the man page helped, but it could be a little clearer that this is what that does I think.Merge tag 'v1.24'