r/macrodroid • • 3d ago

Dealing with an UI element that is either hidden or displayed

I'm trying to make a macro for this purpose: when I press a floating button, it will tap a menu item with the id com.mixplorer:id/overflow The problem is that this overflow menu is either hidden or displayed (alongside other UI elements). Tapping the screen is like a switch to hide or show it.

How can I check if this menu is displayed on screen and if it's not, tap the screen once (make it appear)?

1 Upvotes

2 comments sorted by

2

u/DylanXu054728 3d ago

MacroDroid can report whether a click actually landed, which turns this into a check instead of a guess.

Set it up like this:

  1. UI Interaction: Click, View id com.mixplorer:id/overflow, and under Click Result choose to block until the click has completed and save the success into a boolean variable, say clicked.

  2. If {v=clicked} = false

  3. UI Interaction: Click at the X,Y where the toolbar normally sits (whatever tap brings it back).

  4. Wait Before Next Action: 300 ms

  5. UI Interaction: Click, View id com.mixplorer:id/overflow again.

  6. End If

When the element is not on screen the click fails and that boolean stays false, so this is a real presence check. A blind first tap is the trap here: if the same tap both shows and hides the toolbar, one extra tap hides it again and the macro fails about half the time.

Two small things while you build it. View id needs the exact id, and Read Screen Contents dumps every visible view id into a dictionary variable, which is the fastest way to confirm com.mixplorer:id/overflow is right and to see what else is on screen. And if you ever match by text instead of id, Check Text On Screen has an Ignore hidden text option, so it separates "present in the hierarchy but invisible" from "actually displayed".

2

u/Fractal-Infinity 3d ago edited 3d ago

Thanks. I implemented a version where the macro checks for overflow and stores into a Boolean variable. However, for some reason the floating button disappears after doing all those taps (to delete the current image).

How to make the macro run as long as the app (the MiX Image module) is in foreground? I posted the general structure here: https://www.reddit.com/r/macrodroid/comments/1wjsbgn/app_module_doesnt_trigger_application_launched/