Depends on the app and other conditions, there are basically 2 ways to do it
1.
UI event, and look up for the text when it appear. This will delay up to 1 second because of the accessibility, before the clicking can start. However not every app can use this, since not every UI changes involved lookup-able UI Event. Use this if the app support it and you don't mind the 1 second latency.
2.
Looped Control UI, execute the flow by other trigger (example app task started), then looped-sleep-check for that OK button to appear; while checking for the stop button too. Compatible to most app, but the looped-sleep Control UI can slow down other Control UI operation (if other flow triggered at the same time). It also wakelock the CPU, so you have to make sure the loop has some escape mechanism to stop the script after certain amount of time (timeout if the button not found).
For UI event, you can try to simulate the OK button and stop button as they appear. Go back to Automagic, at the trigger UI event and check the RECENT event and see if those button appear. If there is you can try to use that as the trigger and follow by Control UI to click that button.
For Looped Control UI, you need to use while() and put some condition to check at the inner lines. Example
Code: Select all
loop = 0;
while(getTextById("android:id/button1") != "STOP" AND loop < 100)
{
if(getTextById("android:id/button2") == "OK")
clickById("android:id/button2");
sleep(1000);
loop = loop + 1;
}
{loop} is for the escape mechanism, so your script doesn't run forever. Adjust the 100 to the value you can tolerate or expect that the script should have stopped.
It will check for the button1, if it is not "STOP" (if the button not there, it will be null), then loop the script.
The if() check for the "OK" button, if exist, click it.
sleep(1000) and increment the loop. Adjust the sleep to the latency you can tolerate. Too low value will have lower latency, but script executing too many times and loop achieved faster. Too high value will have lower execution but higher latency, the delay can sometimes be noticeably painful. So try to find the optimal value. You can check more detail at the other thread :
viewtopic.php?f=5&t=7108
The same applies to the
Ready and
Try Again scenario. YOu have to replace it with the App element Id.