I am using the Paste action for first time. It doesn't work.

Dan567

Member
I have a very simple macro. All it does is a Paste.

The error I see in the log is:
Paste failed (could not detect current UI focus)

I am running on a Samsung Galaxy Tab S7+ running Android 11.
I tried to paste into Firefox, Microsoft Word, and Samsung Messages.
Nothing was pasted on any of them.
Any suggestions would be appreciated.
 
Last edited:

Dm114

Well-known member
I have a very simple macro. All it does is a Paste.

I am running on a Samsung Galaxy Tab S7+ running Android 11.
I tried to paste into Firefox, Microsoft Word, and Samsung Messages.
Nothing was pasted on any of them.
Any suggestions would be appreciated.
Before pasting you have to put the pointer in a 'pastable' field. Otherwise it won't paste anywhere on the screen.

Generally, you have to position the pointer in such a field (depending on the app) prior to pasting with another UI action such as 'Click...'. Don't forget to add a delay (from 100 to 500ms, depending on your system/device/app) between 2 UI actions.
 

Dan567

Member
Before pasting you have to put the pointer in a 'pastable' field. Otherwise it won't paste anywhere on the screen.

Generally, you have to position the pointer in such a field (depending on the app) prior to pasting with another UI action such as 'Click...'. Don't forget to add a delay (from 100 to 500ms, depending on your system/device/app) between 2 UI actions.

The cursor was already positioned in the field. I am trying to paste in 6 digit SMS codes.
Do I still need the macro to do it somehow?
Is there anyway to say click on current focus? It is already in the right spot on whatever website I am logging into in my browser because it is waiting for me to type in the 6 digit code.

Is there any documentation anywhere for all of this stuff?

This is a macro from the Templates that I started with. I couldn't get it to work and that is why I created my simple example.

I looked through a majority of the Macros in the Templates and couldn't figure this out.

I must have something set wrong somewhere.
 
Last edited:

420

Active member
The cursor was already positioned in the field. I am trying to paste in 6 digit SMS codes.
Do I still need the macro to do it somehow?
Is there anyway to say click on current focus? It is already in the right spot on whatever website I am logging into in my browser because it is waiting for me to type in the 6 digit code.

Is there any documentation anywhere for all of this stuff?

This is a macro from the Templates that I started with. I couldn't get it to work and that is why I created my simple example.

I looked through a majority of the Macros in the Templates and couldn't figure this out.

I must have something set wrong somewhere.
i might be wrong but won't you "lose focus" on the text field as you press the floating button? it would explain the error in the system log.

i don't know if it helps, but yes there is an action to click on current focus, under ui interaction - click - current focus.
 

Dan567

Member
i might be wrong but won't you "lose focus" on the text field as you press the floating button? it would explain the error in the system log.

i don't know if it helps, but yes there is an action to click on current focus, under ui interaction - click - current focus.
I may have screwed it up by simplifying it. Here is the real macro. I added the click on current focus and it didn't help.

Here is the System Log and the full macro. Everything works except the paste.

09:45 Updated value from 567890 to SmsCode
09:45 Set Variable (s: empty) SmsCode
09:45 Display Dialog: Received code: 567890 / from Daniel Line 2 (+17193089245) Code has been copied to clipboard SmsCode
09:44 Paste failed (Could not detect current UI focus)
:09:44 Wait 1 second SmsCode
09:44 Fill Clipboard '567890' SmsCode
09:44 Paste [lv=s]] SmsCode
09:43 Wait 500 ms SmsCode
09:43 Click current focus item failed (could not detect current UI focus)
09:43 Click [Current focus] SmsCode
:09:43 Vibrate (Blip) SmsCode
09:43 Wait 500 ms SmsCode
09:43 Updated value from Code 567890 to 567890 SmsCode
09:43 Extract text SmsCode
09:43 Updated value from to Code 567890 SmsCode
09:43 Set Variable (s: Code 567890) SmsCode
09:43 Invoking Macro: SmsCode SmsCode
09:43 SMS from Sms Code (Contains: code) SmsCode

 

Dan567

Member
When the Paste action is processed, is the keyboard visible on screen?
Yes. I already thought of that. 😁. I have tried it both ways.
It must be ready because I can just click on paste from the keyboard and it pastes the text in.

Maybe some Macrodroid setting or something is wrong? Or maybe something to do with Android 11?

I also couldn't get the original version of the Macro I used from the Templates section to work. I assume that they had it working since it was in the Templates section. They didn't do a click. If you want to see the original macro, I put it in a previous post.
 

420

Active member
Yes. I already thought of that. 😁. I have tried it both ways.
It must be ready because I can just click on paste from the keyboard and it pastes the text in.

Maybe some Macrodroid setting or something is wrong? Or maybe something to do with Android 11?

I also couldn't get the original version of the Macro I used from the Templates section to work. I assume that they had it working since it was in the Templates section. They didn't do a click. If you want to see the original macro, I put it in a previous post.
i had never used the "UI interaction - copy" before, so i just made a simple macro to test it aswell. (i used volume button long press as trigger)

it doesn't actually paste anything for me, system log gives me the same message you are getting. "paste failed (could not detect current UI focus)"

i'm on android 10 myself, i really don't know what the issue is.. maybe we are missing some permission somewhere...



bit offtopic; the macro specific system log that was recently added does NOT show the error message, i was looking there at first and it got me confused, because it seemed like it all worked fine, maybe this is a bug? it should show the errors right?
 

Dan567

Member
i had never used the "UI interaction - copy" before, so i just made a simple macro to test it aswell. (i used volume button long press as trigger)

it doesn't actually paste anything for me, system log gives me the same message you are getting. "paste failed (could not detect current UI focus)"

i'm on android 10 myself, i really don't know what the issue is.. maybe we are missing some permission somewhere...



bit offtopic; the macro specific system log that was recently added does NOT show the error message, i was looking there at first and it got me confused, because it seemed like it all worked fine, maybe this is a bug? it should show the errors right?

I didn't know there was a macro specific system log. (I have only been using MacroDroid for 3 days. But I have created 7 macros.) I looked at it just now and I don't have the error there either so it must be a bug.

I have tested this Paste on the following devices and it didn't work on any of them:
Samsung Galaxy S20 FE 5G cellphone running Android 11
Samsung Galaxy A11 cellphone running Android 10
Samsung Galaxy Tab S7+ tablet running Android 11
I don't have any devices running an older version of Android. I also don't have any devices that aren't Samsung.

I have turned on every permission possible. All of the ones in System Settings > Apps > MacroDroid > Permissions and all the ones in Accessibility and everything it asked for.

I also turned on these settings in adb:
  • adb shell pm grant com.arlosoft.macrodroid android.permission.WRITE_SECURE_SETTINGS
  • adb shell pm grant com.arlosoft.macrodroid android.permission.CHANGE_CONFIGURATION
  • adb shell pm grant com.arlosoft.macrodroid android.permission.SET_VOLUME_KEY_LONG_PRESS_LISTENER
The only ones I didn't turn on were these:
  • adb shell pm grant com.arlosoft.macrodroid android.permission.DUMP
  • adb shell pm grant com.arlosoft.macrodroid android.permission.READ_LOGS
  • adb shell pm grant com.arlosoft.macrodroid.helper android.permission.WRITE_SECURE_SETTINGS
I greatly appreciate your help.
 

Dm114

Well-known member
The cursor was already positioned in the field. I am trying to paste in 6 digit SMS codes.
Do I still need the macro to do it somehow?
Is there anyway to say click on current focus? It is already in the right spot on whatever website I am logging into in my browser because it is waiting for me to type in the 6 digit code.

Is there any documentation anywhere for all of this stuff?

This is a macro from the Templates that I started with. I couldn't get it to work and that is why I created my simple example.

I looked through a majority of the Macros in the Templates and couldn't figure this out.

I must have something set wrong somewhere.
In the macro I've called 'SMScode', I haven't added a click action to set focus on the input field because these are generally impossible to identify and/or can be located anywhere on the screen. So, asap screen with input field appears, I manually click on the field while waiting for SMS arrival.

If everything is ok, the macro pastes the code. Otherwise, I paste it manually.
 
Last edited:

Dan567

Member
In the macro I've called 'SMScode', I haven't added a click action to set focus on the input field because these are generally impossible to identify and/or can be located anywhere on the screen. So, asap screen with input field appears, I manually click on the field while waiting for SMS arrival.

If everything is ok, the macro pastes the code. Otherwise, I paste it manually.

Thanks for your macro. I just started using MacroDroid 3 days ago and the examples help a lot.

So have you seen the problem before of not being able to paste even though the correct app is open and the input field is selected and the keyboard is open?

I have tried in Firefox and Microsoft Word and it didn't work in either. I keep getting the error: "Paste failed (could not detect current UI focus)".
 

420

Active member
ok, so i tried to test one of the other UI interaction actions and that one didn't work either, it gave the following error message;

"cannot perform click as x,y location (could not detect current UI root node) please try rebooting your device"

so i rebooted, and right away i got a notification from macrodroid saying it needs "accessibility service - user interface interaction permission"

kind of strange that it only shows that notifcation after rebooting, but i gave the permission and now it all works fine...

you should check if you have given that permission, if that doesn't fix it then i don't know...
 

Dan567

Member
ok, so i tried to test one of the other UI interaction actions and that one didn't work either, it gave the following error message;

"cannot perform click as x,y location (could not detect current UI root node) please try rebooting your device"

so i rebooted, and right away i got a notification from macrodroid saying it needs "accessibility service - user interface interaction permission"

kind of strange that it only shows that notifcation after rebooting, but i gave the permission and now it all works fine...

you should check if you have given that permission, if that doesn't fix it then i don't know...

Unfortunately, I have already given that permission. I also rebooted yesterday.

Thanks for your help.
 

Dm114

Well-known member
Thanks for your macro. I just started using MacroDroid 3 days ago and the examples help a lot.

So have you seen the problem before of not being able to paste even though the correct app is open and the input field is selected and the keyboard is open?

I have tried in Firefox and Microsoft Word and it didn't work in either. I keep getting the error: "Paste failed (could not detect current UI focus)".
In banking apps I even didn't try because input fields are not easy to locate. As I don't use this function (copy/paste code) daily but only from time ti time, I must admit that I didn't want to spend to much time to solve a (probably) unsolvable problem!

On the other hand, I'm used to paste quite often URLs in Firefox and it works fine. Don't forget to position the cursor somewhere in the input field prior to pasting (with a delay between the 2 UI actions).
 

Dan567

Member
Something I did yesterday fixed the problem. I don't know which change fixed it because yesterday I was testing with Microsoft Word. I found out today that Paste won't work with Microsoft Word. So when I switched to testing with Firefox today, it worked.

Thanks everybody for your help.

If anybody is curious, this is my final Macro:
 

xavmd

New member
@Dan567 thk for your final macro.
I just can't see how you set variable with "s:[sms_message]"
my var is named telnum.
I got:
define telnum>Expression and then a list of Add Special Text and sms_message or sms_number is not there!
MD V5.7
Edit.
Sorry, on a newer phone (MDV5.14) option choice is much greater.
 
Last edited:
Top