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

Can't Ctrl+C text from Android to PC #145

Closed
KeronCyst opened this issue May 10, 2018 · 28 comments
Closed

Can't Ctrl+C text from Android to PC #145

KeronCyst opened this issue May 10, 2018 · 28 comments

Comments

@KeronCyst
Copy link

Vysor can do this, I believe, but scrcpy v1.1 doesn't seem to be doing anything on my Huawei Honor 5X.

@rom1v
Copy link
Collaborator

rom1v commented May 10, 2018

For information, this feature would have the same implications as #8 (comment).

@paoloramos
Copy link

I've read the implications as seen in #8 comment ... but I would really love this feature :)

@garbb
Copy link

garbb commented May 11, 2019

Could something like the code from clipper be used to get device clipboard text and write to PC clipboard when you press ctrl+c with scrcpy window focused?
Right now with clipper app I can do adb -s shell am broadcast -a clipper.get to clipboard contents with adb, but it would be very cool to have this feature integrated with scrcpy.

@garbb
Copy link

garbb commented May 26, 2019

I though I would share the hacky solution I am using to get copying from device to PC working with scrcpy. I don't know if it is useful at all for scrcpy development but maybe it will be of use to someone.

I am using a tasker profile to send the clipboard contents to logcat any time the clipboard changes:
ClipboardToLogcat.prf.xml.txt (rename to .xml to import into tasker)

Profile: ClipboardToLogcat (27)
	Event: Variable Set [ Variable:%CLIP Value:* User Variables Only:Off ]
Enter: Anon (40)
	A1: [X] Flash [ Text:%CLIP Long:Off ] 
	A2: Run Shell [ Command:log -p v -t clipboard-BEGIN  Timeout (Seconds):0 Use Root:Off Store Output In: Store Errors In: Store Result In: ] 
	A3: Run Shell [ Command:log -p v -t clipboard  %CLIP Timeout (Seconds):0 Use Root:Off Store Output In: Store Errors In: Store Result In: ] 
	A4: Run Shell [ Command:log -p v -t clipboard-END  Timeout (Seconds):0 Use Root:Off Store Output In: Store Errors In: Store Result In: ] 

It looks like this in logcat clipboard clipboard-BEGIN clipboard-END *:S

V/clipboard-BEGIN( 2413):
V/clipboard( 2416): Line one
V/clipboard( 2416): Line two
V/clipboard( 2416): Line three
V/clipboard-END( 2419):

Then I have a script that I leave running while I am running scrcpy on my PC that continuously monitors logcat with another adb.exe instance and puts the output into the windows clipboard.

rom1v added a commit that referenced this issue May 30, 2019
On Ctrl+C:
 - the client sends a GET_CLIPBOARD command to the device;
 - the device retrieve its current clipboard text and sends it in a
   GET_CLIPBOARD device event;
 - the client sets this text as the system clipboard text, so that it
   can be pasted in another application.

Fixes <#145>
@rom1v
Copy link
Collaborator

rom1v commented May 30, 2019

I implemented it on the dev branch (see commits).

(the feature once all the preparation was done is implemented by 63c078e)

To copy from the device to the computer:

  1. put something in the device clipboard (select a text, press "Copy");
  2. press Ctrl+c in scrcpy;
  3. paste in any application on the computer.

To make it possible, I added a socket to send controls and video stream separately (ec71a3f).

While I was there, I also implemented the other direction (c13a243), to copy from the computer to the device clipboard (without pasting), with Ctrl+Shift+v. Contrary to events injection, this preserves the UTF-8 content exactly, so the text is not broken by special characters, and can be pasted "manually" on Android. (see #413)


I also refactored other things, in the end there are a lot of technical changes:

 48 files changed, 1406 insertions(+), 538 deletions(-)

So please test the dev branch and report any regression or other bugs 😉 Thank you.

@giorgiobeggiora
Copy link

Doesn't work on Mac (using 1.10)

@rom1v
Copy link
Collaborator

rom1v commented Sep 20, 2019

@giorgiobeggiora Since v1.10, copy is Cmd+C on MacOS.

Note that it copy your current Android clipboard, so you must have selected some text then press "Copy" to put some text in the clipboard.

@giorgiobeggiora
Copy link

I followed the instructions, but the copy/paste from device to mac does not work :(

@rom1v
Copy link
Collaborator

rom1v commented Sep 20, 2019

Do you use Android 10? #796

@giorgiobeggiora
Copy link

OnePlus 6 (A6000) with Android 9 updated to August 2019 (OxygenOS 9.0.8)

@NewUserHa
Copy link

in some app, clicked copy button, then press c-c in scrcpy to get the clipboard, then c-v on pc. it worked but only pasted part of a very long text.
would you fix? thanks!
@rom1v

@rom1v
Copy link
Collaborator

rom1v commented Jan 28, 2020

Hmmm, yes, it is limited to 4k:

#define DEVICE_MSG_TEXT_MAX_LENGTH 4093

public static final int CLIPBOARD_TEXT_MAX_LENGTH = 4093;

#define CONTROL_MSG_CLIPBOARD_TEXT_MAX_LENGTH 4093

public static final int CLIPBOARD_TEXT_MAX_LENGTH = 4093;

We want some limit (to avoid arbitrary high values), but it is possible to increase (maybe to 64k to avoid changing the type?)

Could you open a separate issue, please?

@NewUserHa
Copy link

#1117

@oyekanwahab
Copy link

oyekanwahab commented May 19, 2020

I implemented it on the dev branch (see commits).

(the feature once all the preparation was done is implemented by 63c078e)

To copy from the device to the computer:

  1. put something in the device clipboard (select a text, press "Copy");
  2. press Ctrl+c in scrcpy;
  3. paste in any application on the computer.

To make it possible, I added a socket to send controls and video stream separately (ec71a3f).

While I was there, I also implemented the other direction (c13a243), to copy from the computer to the device clipboard (without pasting), with Ctrl+Shift+v. Contrary to events injection, this preserves the UTF-8 content exactly, so the text is not broken by special characters, and can be pasted "manually" on Android. (see #413)

I also refactored other things, in the end there are a lot of technical changes:

 48 files changed, 1406 insertions(+), 538 deletions(-)

So please test the dev branch and report any regression or other bugs 😉 Thank you.

I tried this, but was still not able to move text from android to PC, am only able yo copy from PC to android now

Using scrcpy 1.8 x64 bit

@hcet14
Copy link

hcet14 commented May 20, 2020

I tried this, but was still not able to move text from android to PC, am only able yo copy from PC to android now>

Same here. x64 W7 and W10 with 1.11, 1.12.1, 1.13

@rom1v
Copy link
Collaborator

rom1v commented May 20, 2020

I tried this, but was still not able to move text from android to PC

After step 1 and 2, does it print INFO: Device clipboard copied in the console?

@oyekanwahab
Copy link

oyekanwahab commented May 20, 2020 via email

@oyekanwahab
Copy link

@KeronCyst can you please reopen this issue

@KeronCyst
Copy link
Author

@KeronCyst can you please reopen this issue

Why? It's been working fine for me. Are you talking about the character count limit? If so, that should be a separate issue, no?

@oyekanwahab
Copy link

@KeronCyst
it this same issue Can't Ctrl+C text from Android to PC, read above it not only me that is having the issue

@rom1v
Copy link
Collaborator

rom1v commented May 23, 2020

@oyekanwahab Could you test #1423 please?

@oyekanwahab
Copy link

ok let me try it

@oyekanwahab
Copy link

@rom1v it worked,

thanks alot

@AndroidDeveloperLB
Copy link

@rom1v It seems the issue occurs now again, this time on Android 14 on Honor magic4 pro device.
Copying from pc to device works, but not the opposite. Is it a known issue or should I create a new one here somewhere?
It's weird because CTRL+C and CTRL+X work fine on the device.

@rom1v
Copy link
Collaborator

rom1v commented May 29, 2024

There's probably a new security setting to enable/disable in developer options to allow clipboard capture.

@AndroidDeveloperLB
Copy link

@rom1v Because of Honor? An unofficial thing?
I don't remember I had such a thing on my Pixel 6.

@rom1v
Copy link
Collaborator

rom1v commented May 29, 2024

@AndroidDeveloperLB You should check. I don't know. It works on Android 14 on a Pixel 8.

@AndroidDeveloperLB
Copy link

@rom1v I know it works. I have Pixel 6 and I can see it works.
On this device though it doesn't. I've now searched "clipboard" and "copy" in the settings. Didn't see anything related to this. Also searched manually over all the items in developer options.

Should I create a new report, as it's probably specific to this device/OEM?

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

No branches or pull requests

9 participants