AutoInput Using UI Query Variables

Discussion in 'AutoApps' started by Ron Parker, Jun 16, 2017.

  1. Ron Parker

    Ron Parker New Member

    Joined:
    Jun 8, 2017
    Messages:
    19
    Likes Received:
    2
    I created a profile that uses AutoInput to turn hotspot on/off. It just clicks the hotspot button. But now I'd like to add some smarts to it: To turn on, click the button only if it's already off.
    I run ui query and see the array element Off(). Since I see "Off" on the screen, I select it, name it "off". In ui query "Variables", I see:
    android:id/summary=:=off()
    I don't know what that means. I'm just trying to figure out how to create an if statement that will only click the button if it's off. Can someone point me in the right direction?
    Thanks!
     

    Attached Files:

  2. Ron Parker

    Ron Parker New Member

    Joined:
    Jun 8, 2017
    Messages:
    19
    Likes Received:
    2
    Figured it out. Don't need to use Off() variable at all. Use default UI Query variable %aitext() which lists the text on the screen. That way I can tell which screen says "On" and which says "Off". Here's the code in case it helps anyone else:
    Code (Text):
    Used a little guidance from here https://www.reddit.com/r/tasker/comments/3qd417/ui_query_for_dummies/ to figure out how to use UI Query.
    Profile: Turn Hotspot On Off (13)
    State: BT Connected [ Name:Rons-Xtrons Address:* ]
    Enter: Hotspot On 02 (17)
    A1: Variable Set [ Name:%Hotspot To:0 Recurse Variables:Off Do Maths:Off Append:Off ]
    A2: Launch App [ App:Settings:Hotspot and Tethering Data: Exclude From Recent Apps:Off Always Start New Copy:Off ]
    A3: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ]
    A4: AutoInput UI Query [ Configuration:App Package: com.android.settings
    Variables: off()
    Only Visible: true Timeout (Seconds):20 ]
    A5: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ]
    A6: Actions [ Configuration:Action: Tap Method: Point (x,y) Selection: 958 315 Timeout (Seconds):30 ] If [ %aitext() ~ *Off* ]
    A7: Variable Set [ Name:%Hotspot To:1 Recurse Variables:Off Do Maths:Off Append:Off ] If [ %aitext() ~ *Off* ]
    Exit: Hotspot Off 02 (19)
    A1: Launch App [ App:Settings:Hotspot and Tethering Data: Exclude From Recent Apps:Off Always Start New Copy:Off ]
    A2: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ]
    A3: AutoInput UI Query [ Configuration:App Package: com.android.settings
    Variables: on()
    Only Visible: true Timeout (Seconds):20 ]
    A4: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ]
    A5: Actions [ Configuration:Action: Tap Method: Point (x,y) Selection: 958 315 Timeout (Seconds):30 ] If [ %aitext() ~ *On* ]
    A6: Variable Set [ Name:%Hotspot To:0 Recurse Variables:Off Do Maths:Off Append:Off ] If [ %aitext() ~ *On* ]
    A7: Wait [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ]
    A8: WiFi [ Set:On ] If [ %Hotspot eq 0 ]
     
     
    yomen9 likes this.
: ui query, hotspot

Share This Page