How to reverse the dictionary entries of a read screen content variable?

Ayano

Member
I have a dictionary array loop that takes dictionary entries obtained thanks to read screen content.

Inside this loop I have an if with a click view id in it that through a setting manages to make me click the buttons I want using their view id.

This happens from top to bottom, from the first entry to the last, from the first button at the top to the last button at the bottom that I can see in my screen.

I would like to do the exact same thing though by reversing the order of the dictionary entries, this way the clicks will start from the last button at the bottom to the first button at the top, this is my goal.

Is this possible?
 

Dev777

Active member
This might be of help. I'll be of help if you need any further assistance.
 

Attachments

  • Reverse_iterate.macro
    5.8 KB · Views: 6

Ayano

Member
This might be of help. I'll be of help if you need any further assistance.
I have this macro:

It reads the screen, so I can know if there are buttons in the screen.

If there are keys in the dictionary that contain the View id of the button I want to press then press them.

Once done reset the dictionary and make it empty.

After that I will put a scroll to do the same thing again.

What I want is to press these buttons in succession, however these buttons have a slightly different id, e.g. com.banana$1 com.banana$2, so that is why it is used contains com.banana$*

What I get is that the clicks only slow because of the amount of elements in the dictionary, however I can click them all and they click one at a time from 'top to bottom.

Do you think it is possible to implement the content of your macro so that the button clicks happen from the bottom to the top or is there an even more efficient way to do what I would like? I have no idea, however so far this is the best solution I have found for now.
 

Attachments

  • Screenshot_20240229_181944_com.arlosoft.macrodroid.jpg
    Screenshot_20240229_181944_com.arlosoft.macrodroid.jpg
    422.1 KB · Views: 13

Dev777

Active member
With JavaScript you can extract only the keys containing com.banana$ then save them in a string variable in reverse then perform action on them like so
 

Attachments

  • Reverse_iterate 2.macro
    7.5 KB · Views: 6

Ayano

Member
With JavaScript you can extract only the keys containing com.banana$ then save them in a string variable in reverse then perform action on them like so
I added read screen content and I set the variable buttons check to memorize the dictionary entry obtained thanks to screen content.
Then I changed the button name com.. in the JavaScript code.

Now what I've to change?
 

Attachments

  • Screenshot_20240229_210529_com.arlosoft.macrodroid.jpg
    Screenshot_20240229_210529_com.arlosoft.macrodroid.jpg
    430.9 KB · Views: 11

Ayano

Member
Have you tested it. It should now click the buttons in reverse order
bro about this, it works perfectly and I've another idea, how can I add the +20x in this script? It clicks directly the element but I want to do the same thing, +20x it's the same thing of the other macro but I don't know hot to do it with this Javascript script l
 

Dev777

Active member
It's possible but read screen action doesn't provide the coordinates. How are you intending to get the X and Y coordinates?
 

Ayano

Member
It's possible but read screen action doesn't provide the coordinates. How are you intending to get the X and Y coordinates?
thanks to auto input I can fake a click on an element and store the coordinate in a string and then do the split array like you told me.
I can only do in this way.

So the process with auto input is this:
check if there are elements of the view id I want and click it, then because it's a particular element the click doesn't happened BUT it store it's coordinate, the thing that matter.

So I'm ready with the actions to do when I find the elements but when there aren't anymore elements It only drops the phone's notification bar because it doesn't find anything.

So in this case the problem is not knowing what to do, but if and when to do it because if it doesn't find anything it bugs, I need a check.
 

Ayano

Member
It's possible but read screen action doesn't provide the coordinates. How are you intending to get the X and Y coordinates?
basically:
if there items with this view Id do the actions I want No matter how many times there are items, then do another check to see if there are any items And do the same thing, if there are no more items with this ID on the screen then continue the macro, then scroll down and repeat the same operation.
 

Ayano

Member
If you send a macro sample I can try to edit it for you
Sorry for all the comments, I wanted to make you understand perfectly the steps, the I point of view and what I want, please also read the description of the macro.

If you want, you can also try to optimize my macro if it feels like it could be done even better and with fewer steps. Thank you for all the help you are giving me.
 
Last edited:
Top