ContolUI - click()

Post your questions and help other users.

Moderator: Martin

Post Reply
rich_r
Posts: 3
Joined: 25 Apr 2013 17:36

ContolUI - click()

Post by rich_r » 07 Oct 2013 17:54

Hi. I just got an LG G2 (Verizon model) and I am trying to create a flow that will turn on the hotspot. The normal command to manage hotspot does not work. So I am trying to use ControlUI. There is a separate App (as well as entry in Setting) to manage the hotspot. I have used the Launch App Action to launch the Hotspot app and now I need to "click" a checkbox that has the text "Mobile Hotspot". That does not seem to do anything (it seems that "click" may only work with a button) how can I use controlUI to click a checkbox?

My script is basically:

Code: Select all

sleep(1000);
clicked = click("Mobile Hotspot");
if (clicked)
{
    click("Ok"); // dismiss dialog
}
back();
I would appreciate any suggestions. I would also like to see better documentation on what we can do with controlUI and scripting.

thanks.

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

Re: ContolUI - click()

Post by Martin » 07 Oct 2013 18:23

Hi,

You can use the overlay control to show information about the currently shown user interface. Press the button Show Overlay Control in action Control UI to show the two red buttons Info and Close at the top of the screen.
Press the Info-button to analyze the control elements currently shown on screen. Controllable elements are highlighted with a green border. The back button hides the overlay with the highlighted elements again.

Ensure that the overlay control buttons are visible then open the settings page containing your mobile hotspot checkbox, press the Info-button again and select the label of the checkbox. A dialog with sample scripts should be shown. Clicking the label of a settings checkbox usually allows to select a sample script like click("Mobile Hotspot"). Selecting the checkmark of a settings checkbox usually allows to select check(x, y) or uncheck(x,y). Selecting the sample scripts in the popup appends the selected script to the clipboard so you can click a few elements, return to the Control UI action and paste the script.

Note that it's usually a good idea to use an action Launch App to directly start the appropriate settings page, something like this:
-action 'Launch App'
-action 'Sleep: 1s'
-action 'Control UI: check(x, y)'

Regards,
Martin

rich_r
Posts: 3
Joined: 25 Apr 2013 17:36

Re: ContolUI - click()

Post by rich_r » 07 Oct 2013 19:29

Thank you that worked. With a little work. The Info command recommended click("Mobile Hotspot") first and then click(x,y). The click("Mobile Hotspot") did not work, but click(x.y) did. Can you elaborate on when we should use one syntax versus the other?

Additionally, you recommended
-action 'Launch App'
-action 'Sleep: 1s'
-action 'Control UI: check(x, y)'

I had:
-action 'Launch App'
-action 'Control UI' with script to sleep(1000) first.

Is there any particular reason you prefer the sleep action rather than a scripted sleep(). Putting the sleep() in seemed better to me since I will need an additional sleep after the checkbox is set?

thanks again.

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

Re: ContolUI - click()

Post by Martin » 07 Oct 2013 20:23

I usually prefer the click("text") variant since it is more robust when the user interface is slightly scrolled. This option does not work when the user interface contains the same text on multiple control elements or when the element is composed of other elements. Using the click-function with the coordinates is the only working option in this case. For some interfaces it might even be required to directly target the checkmark of the checkbox.

Using the sleep-function directly in the script is perfectly fine and should not make a difference.

rich_r
Posts: 3
Joined: 25 Apr 2013 17:36

Re: ContolUI - click()

Post by rich_r » 07 Oct 2013 20:42

Ok, thanks for the very clear explanation.

Post Reply