Page 1 of 1

Another question regarding Control UI

Posted: 14 Jul 2017 17:10
by husky
Hello,

I have the following Control UI:

check("Protection OFF");
If(IsChecked("Protection OFF"))
{
click(("Protection OFF");
sleep(1000);
get_data=getTextInActiveWindow();
}

Question:

1. The get_data above does not return anything. Is that the right way to code it?
2. Assume that I want to send a message telling me that the status was found OFF every time it happens.
Is there a way to insert a variable with a message inside the IF statement and pass the variable to a Write File outside the Control UI?

Thank You
Husky

Re: Another question regarding Control UI

Posted: 15 Jul 2017 20:00
by Martin
Hi,

The script looks almost OK, just the case sensitivity might be a problem: if and isChecked have to begin with a lower case i. I assume that this is not the problem since you would get other kind of error messages by Automagic in this case.
get_data=getTextInActiveWindow(); looks OK to me. Try to alter the sleep duration, this can make a difference sometimes.

You could assign the return value of the isChecked function to a variable like was_checked and then use a condition Expression: was_checked to execute the Write to File action only when the checkbox indeed was checked.

Regards,
Martin

Re: Another question regarding Control UI

Posted: 17 Jul 2017 21:08
by husky
Hi Martin,

I'm a bit lost here. How and where do you code the was_checked inside the Control UI.
I tried to create was_checked="false" at the very beginning of the script (inside the Control UI).
Then, inside the {...} I change it was_checked="true" since the button was in the OFF state. This is working.

No matter what the button status, it always comes back as was-checked=true.

So the question of how and where the was_checked should be located in the code to have the correct value returned.



Thank You for your patience


Husky

Re: Another question regarding Control UI

Posted: 19 Jul 2017 18:55
by Martin
I had something like this in mind:
was_checked = isChecked("Protection OFF");

and then in condition Expression only the following text:
was_checked

Regards,
Martin

Re: Another question regarding Control UI

Posted: 20 Jul 2017 16:16
by husky
Hi Martin,


Based on your suggestion, the flow now works with one problem I need to fix.
When I call Control UI second time in the same flow, the damn app I'm checking goes belly up. I wonder why.

Probably will have to change my approach to the problem by calling a second flow to set the OFF switch to ON. Positively a no-brainer.



Thanks for the help

Best Regards


Husky

Re: Another question regarding Control UI

Posted: 21 Jul 2017 19:24
by Martin
Hi,

Does belly up mean crash? You could enable developer options and take a bug report and send it to me but it's more likely that something in the other app needs to be fixed. Unfortunately Android behaves slightly different in some UI areas when accessibility services are enabled and developers of apps often don't test with accessibility services turned on.

Regards,
Martin

Re: Another question regarding Control UI

Posted: 07 Aug 2017 23:23
by husky
Oh Man !!!

I solved the problem and was not expecting a reply from you. My bad.

Sorry, belly up is same as crash. Will avoid using of expressions and slang.

Posting another question right now.


Regards


Husky