Page 1 of 1
Paste() not working.
Posted: 06 Feb 2020 12:24
by robchoc
I have a very simple script and want to be able to paste the contents of the clipboard into the search box in a browser.
I can get my cursor to show in the search box but when I use paste() it does nothing. What am I doing wrong?
Thanks for the help.
Re: Paste() not working.
Posted: 06 Feb 2020 18:34
by Desmanto
What is the browser and hwo do you focus to the search box. If you are using chrome, try to use focusById() first, then paste().
Code: Select all
focusById("com.android.chrome:id/url_bar");
sleep(200);
paste();
Adjust the sleep to be enough time. Best is to set to sleep(1000) at first try.
Re: Paste() not working.
Posted: 07 Feb 2020 10:05
by robchoc
I'm using Firefox
And this is my script that paste does not work, focus works just fine:
Code: Select all
focusById("mib"); (I got that using info from show overlay)
sleep(3000);
paste();
Re: Paste() not working.
Posted: 07 Feb 2020 17:59
by Micky Micky
Isn't this related to the clipboard restriction?
Paste() works in Automagic. Try it in the Control UI script window.
Hope this helps.
Re: Paste() not working.
Posted: 08 Feb 2020 09:45
by robchoc
Is there a way around this?
So is it possible to do a long press (no root) until paste pops up and then click that?
EDIT: I got it to work using sendkey ctrl + V
Re: Paste() not working.
Posted: 08 Feb 2020 18:08
by Desmanto
@robhoc : I don't your previous action before this CUI. But if you are on android 10 already and automagci can't access clipboard while in firefox, you can popup some input dialog, message dialog or similar, to make Automagic foreground for a while, then have action copy text from clipboard. After the clipboard copied, you can use it then anywhere else. In the case of the url bar, most of the time, you don't need to paste. Use setText2ById() instead. At my chrome, it is
Code: Select all
setText2ById("com.android.chrome:id/url_bar", clip_data);
But if you what you want is simply to open a new tab in browser, just use action Open URL in browser, pick firefox, that's it. It is much faster and you don't have to be in firefox to do it. You can trigger the URL from anywhere.