How can I create a variable that increases decreases based on ID?

Ayano

Member
I want to click a button, this button wraps can be in different y positions:

For example:

Wraps the button can be

x100 y100

or

x100 y 200

I want to be able to identify where the button is, and based on its location make a series of clicks going from above the button and having a distance of 10y until I get to they I want.

For example:

If the button is located at

x100 y100
the clicks should start at y90 x100, then y80 x100, then y70 x100 until they reach x100 y20 where I want them to be.

If the button is located at position

x100 y 2000

Clicks should start at x100 y1990, then x100 y1980 until they reach x100 y20.

The 'x must remain unchanged, I just want to automatically find the Id element and start the clicks above it, without giving the coordinates manually, it must be via variable.

How could I do that?
 

hsurB

Well-known member
Run read screen content action on the screen you are talking about and check saved variable if macrodroid can detect the button you want it to click.
If its some kind of game macrodroid probably won't detect the button and creating the macro is impossible (you would have to set coordinates manually based on your own knowledge). If there is only few cases where the button might be you could try if clicking in few different spots (even if most clicks will miss the button) is fine.
In the next update (I believe the next one) there should be action added that lets you detect the color of pixels on screen so maybe that would be a solution.
There might be some plugins that macrodroid can interact with that would allow you to create this macro but I am afraid I don't know any.

If the button is detectable by macrodroid let us know and we'll guide you how to achieve the rest
 

Ayano

Member
Run read screen content action on the screen you are talking about and check saved variable if macrodroid can detect the button you want it to click.
If its some kind of game macrodroid probably won't detect the button and creating the macro is impossible (you would have to set coordinates manually based on your own knowledge). If there is only few cases where the button might be you could try if clicking in few different spots (even if most clicks will miss the button) is fine.
In the next update (I believe the next one) there should be action added that lets you detect the color of pixels on screen so maybe that would be a solution.
There might be some plugins that macrodroid can interact with that would allow you to create this macro but I am afraid I don't know any.

If the button is detectable by macrodroid let us know and we'll guide you how to achieve the rest
What I've to select, dictionary, key or define manually as variable in read screen content?

Please bro tell me step by step
 

hsurB

Well-known member
Create dictionary variable (or use the one you already have) - This dictionary - Include view ids without text - Last part shouldn't matter.
 

hsurB

Well-known member
Go to that dictionary variable after runing this action and look for something that would be matching the button you want to click
 

Ayano

Member
Go to that dictionary variable after runing this action and look for something that would be matching the button you want to click
Ok did, but I think there's a problem, the thing that I'm looking for it's always the last one, so for example some times is index 204 other times is index 400,it's basically a piece of text, One sentence after another and I have to click on the thing that is under all these sentences, which says next chapter, based on the number of sentences the id of next chapter changes
 

hsurB

Well-known member
But its detectable. Could you try ui interaction - click by text instead x,y coordinates?
 

Ayano

Member
But its detectable. Could you try ui interaction - click by text instead x,y coordinates?
yes you are right, but the thing that I want to do is, to start the series of clicks from above the position of next chapter, so I guess I need to know the exact position of next chapter, so by getting its y, it can start the series of clicks that it then does from that position - 10 and again and again.

As I said, this text next chapter is always at the bottom but not at a specific position, it can vary and if it varies and I give a variable y for example 5000, by mistake I can click it.

So my goal is, don't give a specific y like y5000 and start from here, no, I would like to know the exact location of next chapter so once I get it I can use its y and start the series of clicks from above it.

At least I think I need the exact position id, I don't know bro, what do you think?
 

hsurB

Well-known member
I haven't seen the screen you need to perform actions on but here is idea with the newest version of macrodroid and action - check colour of pixel.

Attached macro was supposted to go from the bottom of screen, check colour of pixel starting from 500;3000, 500;2990 ... and stopping when it finds the end of yellow button.
If your texts look somewhat like buttons and could be detected this way maybe it could help (assuming the X coordinates of that button won't change or its the same even when its moved slightly). this actions is very limited right now since I couldn't perform it more often than once per 300ms so checking more pixels or with lower interval between them than 10 might take time.
Maybe using % of screen would be better here? I am not sure.
Anyway... Here is a macro and screenshot of screen it was checking and yellow button that it was supposted to find the end of (notice that last created key of an array is also Y coordinate where the button ends) so if there was some button above that I would want to click maybe it'd tell me something, right?
I am afraid macrodroid isn't the best tool YET for this particular need
 

Attachments

  • Finding_end_of_button.macro
    22.7 KB · Views: 3
  • Finding_end_of_button.png
    Finding_end_of_button.png
    263.8 KB · Views: 13
  • Screenshot_20240217_162225_r.png
    Screenshot_20240217_162225_r.png
    10.9 KB · Views: 12

Ayano

Member
I haven't seen the screen you need to perform actions on but here is idea with the newest version of macrodroid and action - check colour of pixel.

Attached macro was supposted to go from the bottom of screen, check colour of pixel starting from 500;3000, 500;2990 ... and stopping when it finds the end of yellow button.
If your texts look somewhat like buttons and could be detected this way maybe it could help (assuming the X coordinates of that button won't change or its the same even when its moved slightly). this actions is very limited right now since I couldn't perform it more often than once per 300ms so checking more pixels or with lower interval between them than 10 might take time.
Maybe using % of screen would be better here? I am not sure.
Anyway... Here is a macro and screenshot of screen it was checking and yellow button that it was supposted to find the end of (notice that last created key of an array is also Y coordinate where the button ends) so if there was some button above that I would want to click maybe it'd tell me something, right?
I am afraid macrodroid isn't the best tool YET for this particular need
Thanks for the advice but unfortunately I can't do that because the element that I want to click has the same color as the rest of the background where are other phrases.

With click by view id I can click the element that I want at 100% and I'm wondering about, is it possibile to do the thing that I want with a Javascript script?

Like Identify the element by the view id and store the y coordinate to a variable by using Javascript?
 

Endercraft

Moderator (& bug finder :D)
The JavaScript action can't interact with the outside environment whatsoever. You can pass it variables and get result but no direct interaction is possible.
 
Top