How to copy pre-selected text using UI action?
Moderator: Martin
How to copy pre-selected text using UI action?
Hi Martin.
I have managed to paste a text from the clipboard into a text field which I had in focus.
I also managed to do a "selectAll" using the control UI action with a little script.
But how do I do a "select all" followed by "copy" so the text goes directly to the clipboard without the need for a long click/copy we would normally do?
I have gone through the whole forum, the user help and through the web without success, but I'm convinced I can do it in automagic I just don't know how
Thanks
LED
I have managed to paste a text from the clipboard into a text field which I had in focus.
I also managed to do a "selectAll" using the control UI action with a little script.
But how do I do a "select all" followed by "copy" so the text goes directly to the clipboard without the need for a long click/copy we would normally do?
I have gone through the whole forum, the user help and through the web without success, but I'm convinced I can do it in automagic I just don't know how
Thanks
LED
Re: How to copy pre-selected text using UI action?
Check the Control UI help section again. There is a list of functions you can use and it contains a few different methods to copy text.
Re: How to copy pre-selected text using UI action?
Thanks but I don't know how to use "copy(pattern)"
I want the "pattern" to be the text I pre-selected using the selectAll script. But it doesn't seem to work.
Thanks
I want the "pattern" to be the text I pre-selected using the selectAll script. But it doesn't seem to work.
Thanks
Re: How to copy pre-selected text using UI action?
When you have the text selected, execute function copy(x,y) where x and y are the coordinates of the text field. You can get the coordinates with the helper overlay or phone's developer setting "show pointer location". Also, after selecting the text, you might need to focus on the text field again; focus(x,y).
Re: How to copy pre-selected text using UI action?
Thanks again.
I understand this to be a very particular way, for a very particular app and for an specific location/field on the screen.
I need a command that copies whatever selection I have, on any app, on any screen.
I managed to apply the selected all based on the existing focus, so I don't understand why I cannot simply do the same but copying instead of selecting.
Thanks for the help anyway....but I'm nearly accepting I simply cannot do it.
Maybe if I have a way to ask automagic to dinamically tell me what field/position I'm focused on, then use it to direct it to where to copy the text from....maybe.
Cheers
LED
I understand this to be a very particular way, for a very particular app and for an specific location/field on the screen.
I need a command that copies whatever selection I have, on any app, on any screen.
I managed to apply the selected all based on the existing focus, so I don't understand why I cannot simply do the same but copying instead of selecting.
Thanks for the help anyway....but I'm nearly accepting I simply cannot do it.
Maybe if I have a way to ask automagic to dinamically tell me what field/position I'm focused on, then use it to direct it to where to copy the text from....maybe.
Cheers
LED
Re: How to copy pre-selected text using UI action?
That is because without source(selected text) there is nothing to copy. If you have managed to focus on a text field and select all, simply reapply the focus on the same text field and use same coordinates with copy function. This works in any app that accepts input through Control UI action. You could check what app you have running and define the coordinates in a script per app basis, or something more elaborate.LED wrote:I managed to apply the selected all based on the existing focus, so I don't understand why I cannot simply do the same but copying instead of selecting.
Re: How to copy pre-selected text using UI action?
Hi.
Thanks once again and I'm sorry for being a bit annoying here.
I understand everything you said.
However there is a thing I believe you are missing: I have managed to select the focused text just by applying the "selectAll()" command, which does not require me telling where/what/x,y of what I'm selecting. It just works in the most simplistic way. I focus on something, and the text is selected.
So why, after that, and considering the text is already fully selected, can't I apply a similar command "copy()" without having to specify the location of something automatic has already select and therefore it must know where it is?
Thanks.
LED
Thanks once again and I'm sorry for being a bit annoying here.
I understand everything you said.
However there is a thing I believe you are missing: I have managed to select the focused text just by applying the "selectAll()" command, which does not require me telling where/what/x,y of what I'm selecting. It just works in the most simplistic way. I focus on something, and the text is selected.
So why, after that, and considering the text is already fully selected, can't I apply a similar command "copy()" without having to specify the location of something automatic has already select and therefore it must know where it is?
Thanks.
LED
Re: How to copy pre-selected text using UI action?
Just so you understand what I'm trying to achieve, it is very simple:
I'm creating a widget overlay, which is basically a button, that shows up every time the keyboard pops up. It works, Martin already helped me on that.
Now I'd like to create an action for this button (execute flow).
All this action does is to select the entire focused text field and copy it to the clipboard.
I'd be saving myself from having to long press the text, click select all and select copy (3 actions) but I'd be doing all that in a single click on my widget.
I need to be able to do that anywhere, on any app, on any text field.
Thanks.
I'm creating a widget overlay, which is basically a button, that shows up every time the keyboard pops up. It works, Martin already helped me on that.
Now I'd like to create an action for this button (execute flow).
All this action does is to select the entire focused text field and copy it to the clipboard.
I'd be saving myself from having to long press the text, click select all and select copy (3 actions) but I'd be doing all that in a single click on my widget.
I need to be able to do that anywhere, on any app, on any text field.
Thanks.
Re: How to copy pre-selected text using UI action?
Currently most built-in functions require to specify the target element explicitly, however it would make sense to target the focused component. I'll add it to the todo-list.
Since you are probably already using the Automagic input method, you could also use it to use CTRL C to copy the text to the clipboard. I'm not sure if this works on all Android devices but it seems to work on a Nexus with Android 6.
You can test it by executing sendKey("C", "CTRL_ON");
Regards,
Martin
Since you are probably already using the Automagic input method, you could also use it to use CTRL C to copy the text to the clipboard. I'm not sure if this works on all Android devices but it seems to work on a Nexus with Android 6.
You can test it by executing sendKey("C", "CTRL_ON");
Regards,
Martin
Re: How to copy pre-selected text using UI action?
Thanks Martin.
It just did it. Perfect.
Thanks Murtuma for the exchange of advice.
It is funny I had tried
copy("ctrl+c"). But I obviously did not have a clue how to make it work.
The entire copyall flow can be seen on the attached screen shot.
Cheers guys.
It just did it. Perfect.
Thanks Murtuma for the exchange of advice.
It is funny I had tried
copy("ctrl+c"). But I obviously did not have a clue how to make it work.
The entire copyall flow can be seen on the attached screen shot.
Cheers guys.
- Attachments
-
- Screenshot_2016-05-02-21-15-51.png (119.28 KiB) Viewed 18792 times