Another question regarding Control UI

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
husky
Posts: 132
Joined: 29 Oct 2016 13:41
Location: Omaha, Nebraska, USA
Contact:

Another question regarding Control UI

Post by husky » 14 Jul 2017 17:10

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
"Basic research is what I'm doing when I don't know what I'm doing"

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Another question regarding Control UI

Post by Martin » 15 Jul 2017 20:00

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

User avatar
husky
Posts: 132
Joined: 29 Oct 2016 13:41
Location: Omaha, Nebraska, USA
Contact:

Re: Another question regarding Control UI

Post by husky » 17 Jul 2017 21:08

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
"Basic research is what I'm doing when I don't know what I'm doing"

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Another question regarding Control UI

Post by Martin » 19 Jul 2017 18:55

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

User avatar
husky
Posts: 132
Joined: 29 Oct 2016 13:41
Location: Omaha, Nebraska, USA
Contact:

Re: Another question regarding Control UI

Post by husky » 20 Jul 2017 16:16

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
"Basic research is what I'm doing when I don't know what I'm doing"

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Another question regarding Control UI

Post by Martin » 21 Jul 2017 19:24

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

User avatar
husky
Posts: 132
Joined: 29 Oct 2016 13:41
Location: Omaha, Nebraska, USA
Contact:

Re: Another question regarding Control UI

Post by husky » 07 Aug 2017 23:23

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
"Basic research is what I'm doing when I don't know what I'm doing"

Post Reply