IF Element Contains "text"

Post your questions and help other users.

Moderator: Martin

Post Reply
bungo63
Posts: 2
Joined: 23 Jan 2018 13:07

IF Element Contains "text"

Post by bungo63 » 24 Jan 2018 21:44

Hi. First of all can I say how impressed I am with your app. I have had it on trial for three days and whilst commuting to work I have successful worked out how to set my burgular alarm from Google Home via an IFTT notification. I am so pleased with myself! So I'll definitely be purchasing it.
However I am now a bit stuck.
My simple flow works OK when the house is all secure. But if i try to set the alarm and a window is open, the alarm app warns me to this and asks if I want to continue or cancel. So here's my challenge....
I think I need something like
IF an ELEMENT contains "Window Open" click the element that has the cancel button.
What I need help on is the IF condition, I guess I need to use the GetTextById(x,y); but i don't know how to to test the value of the text.
Could anyone help.

Many Thanks.

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

Re: IF Element Contains "text"

Post by Desmanto » 25 Jan 2018 14:05

You have two ways to do it, either using the UI event as the trigger and use Control UI afterward; or you can use Control UI to loop check for the Window Open elements.
Depends on the case, one can be more efficient than the other. Both need accessibility services to be enabled first (hamburger menu (top left) > Settings > Features & Permissions > Accessibility service)

If the window opened, can trigger UI event, you can use Trigger UI Event, Window Opened, and filter for the text contains "Window Open".
After this, it is Control UI. Use the "Show Overlay Control", you will see 2 red buttons Info and Close.
Press home and navigate to the part until you can get the message "Window Open", after you see it, press Info and tap the button you wanna click. Usually it will show you a lot of option. In this case, you might want to select something call clickById() if it exists. Choose that, tap back and switch back to automagic, paste the script that has been copied using the overlay just now. That is the command to tap the button at that windows. Enable the UI Event and try it out.

The other looping method require while() script, a little more complex. You can find it at my Index, at the Control UI part.
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.

bungo63
Posts: 2
Joined: 23 Jan 2018 13:07

Re: IF Element Contains "text"

Post by bungo63 » 25 Jan 2018 22:16

Dear Desmanto. Thank you for your prompt reply - much appreciated.
I'm not a programmer so I am going to read and digest your suggestion. I'll let you know how I get on - either way! :D

Post Reply