Screen content trigger

aus-wanderer

New member
Hi,

I try to mute YouTube ads with two complementary Screen content triggers that detect the top right text "Visit advertiser" respectively missing it with ^(?!.*?Visit advertiser).*

Unfortunately the missing trigger only comes into action when I tap on the screen after the ad is gone and I wonder why this touch is necessary. It kind of makes the muting useless if it can not be reverted completely automatically.

What do I miss? Could it be a Huawei refresh problem or even a bug?

Greetings
Andy
 

Attachments

  • Screenshot_20230129_211416.jpg
    Screenshot_20230129_211416.jpg
    91.8 KB · Views: 33

Endercraft

Moderator (& bug finder :D)
Hi,

I try to mute YouTube ads with two complementary Screen content triggers that detect the top right text "Visit advertiser" respectively missing it with ^(?!.*?Visit advertiser).*

Unfortunately the missing trigger only comes into action when I tap on the screen after the ad is gone and I wonder why this touch is necessary. It kind of makes the muting useless if it can not be reverted completely automatically.

What do I miss? Could it be a Huawei refresh problem or even a bug?

Greetings
Andy
Have you tried inverting the 2 functions ? 🤣
 

aus-wanderer

New member
Have you tried inverting the 2 functions ? 🤣
What do you mean with 2 functions? One trigger mutes the other unmutes. As I mentioned it principally works but the second screen content trigger seems not to fire when already another screen content trigger was fired before. Only after some screen change or forground app change happens it fires.
 

MacroDroidDev

Administrator
Staff member
Thanks for sharing, so I've looked into the detail of this and the reason it fails is down to the way it functions. It wasn't really designed to trigger on the removal of text from the screen, so your clever workaround for this lack of support is failing because it checks for matching the text against each screen element in turn. Since there are many screen elements, most of them will of course match your regex and the trigger gets in a state where the regex is always true because there is always something on screen that matches the check.

A workaround would be to start a loop to constantly read the screen contents into a dictionary and when no elements in the dictionary match your regex then at that point you can restore the volume (and exit the loop).

It also begs the question that maybe the trigger should support triggering in both transitions where text appears on the screen and text is removed from the screen, which would make this a whole lot easier to support. I think this is a good idea for the long run so will add it to my TODO list!
 

aus-wanderer

New member
Thanks for looking into it and still actively optimizing MacroDroid. Eventually you catched me on this with the pro version since dictionaries aren't available in the free version and your support. Finally I got it to work with your description. However one issue I encountered is: within a dictionary loop it seems impossible to apply the current iterator directly on an if clause. Therefore an extra push variable is necessary.
 

MacroDroidDev

Administrator
Staff member
It seems like a good idea to have a generic constraint to compare two 'values' which can then be filled in with magic text or constant values. I shall add this as soon as I can.
 
Top