In App Loop - Waiting for a Screen in an App to start a Task

489 views
Skip to first unread message

David Devaney, Jr.

unread,
Mar 9, 2015, 3:50:57 AM3/9/15
to tas...@googlegroups.com
Hello all,

I've searched this forum and could not find a way to accomplish what I needed. I was trying to set an Application Profile and then within that Profile, when the app was launched, wait for a specific screen to open and then start a Task. After looking at the documentation and looking through the posts in this "Forum" I couldn't find exactly what I was looking for. However after some experimentation, and seeing a Tip on Ryoen Deprouw's Google+ Community, I was able to get my Task to work.

Basically I was trying to have a task wait for an App to open and then wait for a specific screen to show. At that point it would get the GPS location and put it in the Clipboard, %CLIP, to make it available to paste in the App. Then...I needed it to stay active and wait until that same screen in the App appeared again. Originally I was having a problem because the Task would work once and then just be done. However, using Ryoen's Tip I was able to finally figure out how to get this to work. Originally I tried using AutoInput but I couldn't make that work, mainly due to limitations in the App I'm trying to put data into.

Anyway, I was still having a problem with the loop regardless and the Tip finally helped me figure it out myself. Since I couldn't find any examples of the type of Loop I was looking for I wanted to share my solution here so that other's who might need to loop within an app that doesn't have support for Tasker could benefit. I won't get into specifics, as Tasker users can probably figure this out. If someone needs more details please reply and I'll elaborate. I will say this uses an Application Profile, so it activates when the App is opened. For those wondering, the App is HanDBase, a Database app for Android. I did wind up having to create a HanDBase Form to get this to work though, because of the limitations of the app not sharing Field data with AutoInput.

Here is the XML for my Tasker script. Feel free to use it and modify it as needed. I'll attach it as well if anyone needs to download it.

<TaskerData sr="" dvi="1" tv="4.6u3">
   
<Task sr="task23">
       
<cdate>1425679052429</cdate>
       
<edate>1425793984993</edate>
       
<id>23</id>
       
<nme>GetGPSHanDBase</nme>
       
<pri>10</pri>
       
<Kid sr="Kid">
           
<feat0>android.hardware.location:y</feat0>
           
<feat1>android.hardware.location.gps:y</feat1>
           
<launchID>23</launchID>
           
<pkg>com.mobiledataconsultants.test</pkg>
           
<vnme>1.0</vnme>
           
<vnum>2</vnum>
       
</Kid>
       
<Action sr="act0" ve="7">
           
<code>30</code>
           
<Int sr="arg0" val="0"/>
           
<Int sr="arg1" val="3"/>
           
<Int sr="arg2" val="0"/>
           
<Int sr="arg3" val="0"/>
           
<Int sr="arg4" val="0"/>
       
</Action>
       
<Action sr="act1" ve="7">
           
<code>37</code>
           
<ConditionList sr="if">
               
<Condition sr="c0" ve="3">
                   
<lhs>%WIN</lhs>
                   
<op>3</op>
                   
<rhs>GPS Data</rhs>
               
</Condition>
           
</ConditionList>
       
</Action>
       
<Action sr="act10" ve="7">
           
<code>38</code>
           
<on>false</on>
       
</Action>
       
<Action sr="act11" ve="7">
           
<code>135</code>
           
<Int sr="arg0" val="0"/>
           
<Int sr="arg1" val="2"/>
           
<Str sr="arg2" ve="3"/>
       
</Action>
       
<Action sr="act2" ve="7">
           
<code>35</code>
           
<Int sr="arg0" val="0"/>
           
<Int sr="arg1" val="1"/>
           
<Int sr="arg2" val="0"/>
           
<Int sr="arg3" val="0"/>
           
<Int sr="arg4" val="0"/>
           
<ConditionList sr="if">
               
<Condition sr="c0" ve="3">
                   
<lhs>%WIN</lhs>
                   
<op>2</op>
                   
<rhs>GPS Data</rhs>
               
</Condition>
           
</ConditionList>
       
</Action>
       
<Action sr="act3" ve="7">
           
<code>43</code>
           
<ConditionList sr="if">
               
<Condition sr="c0" ve="3">
                   
<lhs>%WIN</lhs>
                   
<op>2</op>
                   
<rhs>GPS Data</rhs>
               
</Condition>
           
</ConditionList>
       
</Action>
       
<Action sr="act4" ve="7">
           
<code>548</code>
           
<Str sr="arg0" ve="3">Getting GPS Coordinates</Str>
           
<Int sr="arg1" val="0"/>
       
</Action>
       
<Action sr="act5" ve="7">
           
<code>902</code>
           
<Int sr="arg0" val="0"/>
           
<Int sr="arg1" val="10"/>
           
<Int sr="arg2" val="1"/>
           
<Int sr="arg3" val="0"/>
       
</Action>
       
<Action sr="act6" ve="7">
           
<code>547</code>
           
<Str sr="arg0" ve="3">%hdbgps</Str>
           
<Str sr="arg1" ve="3">%LOC</Str>
           
<Int sr="arg2" val="0"/>
           
<Int sr="arg3" val="0"/>
       
</Action>
       
<Action sr="act7" ve="7">
           
<code>105</code>
           
<Str sr="arg0" ve="3">%hdbgps</Str>
           
<Int sr="arg1" val="0"/>
       
</Action>
       
<Action sr="act8" ve="7">
           
<code>548</code>
           
<Str sr="arg0" ve="3">You can now paste the GPS Data.</Str>
           
<Int sr="arg1" val="0"/>
       
</Action>
       
<Action sr="act9" ve="7">
           
<code>35</code>
           
<Int sr="arg0" val="0"/>
           
<Int sr="arg1" val="2"/>
           
<Int sr="arg2" val="0"/>
           
<Int sr="arg3" val="0"/>
           
<Int sr="arg4" val="0"/>
           
<ConditionList sr="if">
               
<Condition sr="c0" ve="3">
                   
<lhs>%WIN</lhs>
                   
<op>3</op>
                   
<rhs>GPS Data</rhs>
               
</Condition>
           
</ConditionList>
       
</Action>
       
<Img sr="icn" ve="2">
           
<nme>hl_location_web_site</nme>
       
</Img>
   
</Task>
</TaskerData>

Unfortunately, when I tried to create it as a Standalone App, it didn't work, I guess I need to do some more studying on that.

I hope this helps.

David

GetGPSHanDBase.tsk.xml

David Devaney, Jr.

unread,
Mar 9, 2015, 3:59:01 AM3/9/15
to tas...@googlegroups.com
I just realized that the Description of my Tasker Script might be more useful, and easier to read, especially for New Tasker Users looking for this type of Loop.

GetGPSHanDBase (23)
 A1
: Wait [ MS:0 Seconds:3 Minutes:0 Hours:0 Days:0 ]
 A2
: If [ %WIN !~ GPS Data ]
 A3
: Wait Until [ MS:0 Seconds:1 Minutes:0 Hours:0 Days:0 ] If [ %WIN ~ GPS Data ]
 A4
: Else If [ %WIN ~ GPS Data ]
 A5
: Flash [ Text:Getting GPS Coordinates Long:Off ]
 A6
: Get Location [ Source:GPS Timeout (Seconds):10 Continue Task Immediately:On Keep Tracking:Off ]
 A7
: Variable Set [ Name:%hdbgps To:%LOC Do Maths:Off Append:Off ]
 A8
: Set Clipboard [ Text:%hdbgps Add:Off ]
 A9
: Flash [ Text:You can now paste the GPS Data. Long:Off ]
 A10
: Wait Until [ MS:0 Seconds:2 Minutes:0 Hours:0 Days:0 ] If [ %WIN !~ GPS Data ]
 A11
: [X] End If
 A12
: Goto [ Type:Action Number Number:2 Label: ]
...

joaomgcd

unread,
Mar 9, 2015, 6:14:30 AM3/9/15
to tas...@googlegroups.com
Don't know what you tried with AutoInput, but it allows you to wait until some text appears inside an app with AutoInput UI Query. Have you tried that?
...

David Devaney, Jr.

unread,
Mar 9, 2015, 5:21:37 PM3/9/15
to tas...@googlegroups.com
I did try that joaomgcd but the results weren't consistent. Of course I'm still new so I may have been doing it wrong. In your forum I responded to a post thinking it might be due to a dynamically created screen but you said it wasn't. I verified that the Variable Setup option worked as you described in AutoApps and it also worked, for the most part, in other HanDBase screens. It just didn't work in the more important Edit Record screen. AutoInput couldn't get any of the fields there so it was harder to check for Text and wait until it appeared to continue. Plus it seemed to be restricted to looking for text at a "point" location, which I couldn't count on. I thought I could get the Screen Name using %aiapp but that didn't seem to work either, maybe because %WIN already does that.

I'll still be posting a version of my script that uses AutoInput to paste the GPS data into a field, but it requires the user to select the field they want it in, rather than having AutoInput detect the with the UI Query.

This post was more about the Loop though. I had a harder time figuring that out or finding any examples so I wanted to post so other's who may need to do the same had an example.


It was just a guess that the dynamic screen was the problem @joaomgcd. I did just try the Variable Setup with AutoApps and I see what you're saying. I also tried it in a different HanDBase screen and it worked, for the most part. It also works in a few other screens, just not the key one, Edit Record.

I was the one who posted in the Tasker Google Group
It was just a guess that the dynamic screen was the problem @joaomgcd. I did just try the Variable Setup with AutoApps and I see what you're saying. I also tried it in a different HanDBase screen and it worked, for the most part. It also works in a few other screens, just not the key one, Edit Record.

I was the one who posted in the Tasker Google Group
It was just a guess that the dynamic screen was the problem @joaomgcd. I did just try the Variable Setup with AutoApps and I see what you're saying. I also tried it in a different HanDBase screen and it worked, for the most part. It also works in a few other screens, just not the key one, Edit Record.

I was the one who posted in the Tasker Google Group

David Devaney, Jr.

unread,
Mar 9, 2015, 5:24:56 PM3/9/15
to tas...@googlegroups.com
Sorry about the extra lines there. They didn't show when I pasted them in, only after I completed the Post.


On Monday, March 9, 2015 at 5:21:37 PM UTC-4, David Devaney, Jr. wrote:
I did try that joaomgcd but the results weren't consistent. Of course I'm still new so I may have been doing it wrong. In your forum I responded to a post thinking it might be due to a dynamically created screen but you said it wasn't. I verified that the Variable Setup option worked as you described in AutoApps and it also worked, for the most part, in other HanDBase screens. It just didn't work in the more important Edit Record screen. AutoInput couldn't get any of the fields there so it was harder to check for Text and wait until it appeared to continue. Plus it seemed to be restricted to looking for text at a "point" location, which I couldn't count on. I thought I could get the Screen Name using %aiapp but that didn't seem to work either, maybe because %WIN already does that.

I'll still be posting a version of my script that uses AutoInput to paste the GPS data into a field, but it requires the user to select the field they want it in, rather than having AutoInput detect the with the UI Query.

This post was more about the Loop though. I had a harder time figuring that out or finding any examples so I wanted to post so other's who may need to do the same had an example.


Reply all
Reply to author
Forward
0 new messages