Elements preloading causing triggers to start

Post your questions and help other users.

Moderator: Martin

Post Reply
TheUnknownBuffalo
Posts: 38
Joined: 09 Aug 2017 07:19

Elements preloading causing triggers to start

Post by TheUnknownBuffalo » 27 Nov 2017 09:47

Hi everyone

I've got a problem with another app, it pre-loads all elements of an advert (loaded in the background) before playing a video, causing the trigger to start prematurely.

I've loaded the overlay, and there is no elementId, just a location, getbounds() and a gettext() showing. I've tried a combination of these commands in a macro (I know I'm missing the syntax on this example)

getbounds("OK")
sleep(10000)
focus("OK")
sleep(10000)
click("OK")

I've also tried inactivewindow.

This one has me stumped, what else can I try?

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Elements preloading causing triggers to start

Post by Desmanto » 27 Nov 2017 10:34

I've got no idea what you wanna do :) I even don't know what is your trigger.

I guess you wanna start a flow when a certain window opened and playing video. Before it, ads came out first. You wanna wait until ads finish, then start clicking skip and load the main video and do something else.

If so, You can still use the same trigger, and use Control UI with loop wait while() to detect the element OK. if no element found, you can detect the unique text using getText, check for text that only appear after the ads.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

TheUnknownBuffalo
Posts: 38
Joined: 09 Aug 2017 07:19

Re: Elements preloading causing triggers to start

Post by TheUnknownBuffalo » 27 Nov 2017 10:39

Dhhh, just realised lol, it's to click an OK button that appears to overlay this advert, then it lets me carry on with the main app

The trigger is currently matches glob *, it then carries down to the controlui script

Is there a way I can do some kind of wait command, if the gettext is on the screen for more than 10 seconds?

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Elements preloading causing triggers to start

Post by Desmanto » 27 Nov 2017 14:59

Yes, just while() like in this thread viewtopic.php?f=6&t=6894

I assum the OK only appear after 10 seconds, so you have to wait when the OK is still not there

Code: Select all

while (NOT contains(getTextInActiveWindow(), "OK"))
  sleep(1000);
Change the OK to match any unique text you can find. Of course OK only will be too wide and can match other text there. So make sure that only appear there or use another word if there is.

If you need the reverse, only wait when the OK is there, just remove the NOT.

PS: This will loop infinitely if the condition is still fullfilled. You might want to AND/OR another condition (time since trigger) to escape out the loop.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply