Check IF app is running in foreground

1,756 views
Skip to first unread message

Jsm

unread,
Sep 4, 2018, 2:58:47 PM9/4/18
to Tasker
Check if app is running in foreground/
background
Help

Guys, I need help with the following :

Profile: if app x or y or z is launched

Task:
Action 1: wait 10 minutes

Action 2: lock screen IF :any of the apps X or y or z is still running in the foreground

Action 3: else, stop

I need help on Action 2 as how to set this IF variable.

I'm new to tasker, so please help.

Basically need this task to stop myself from addictive apps .


Thanks in advance for your valuable suggestions.

C S

unread,
Sep 4, 2018, 4:32:00 PM9/4/18
to Tasker
I don't know about detecting which app is running in foreground, but what I use in a task that gives me ten minutes then blocks data to that app. No data, means most apps stop working. 

Robert Ryan

unread,
Sep 4, 2018, 4:46:45 PM9/4/18
to tas...@googlegroups.com
There are at least two ways to detect what app is in the foreground:
  1. If Tasker's accessibility service is enabled and accessibility is chosen as the App Check Method in Tasker's preferences, then the %WIN variable will often contain the name of the foreground app. 
  2. A much more accurate method is the UI Query action in the AutoInput plug-in. This will give the exact package name of the foreground app. 


--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

Jsm

unread,
Sep 4, 2018, 9:22:53 PM9/4/18
to Tasker
Thank you for your reply.

Could you please check Why is A2 not working?

Eg, I want to setup lock after 10 minutes of running Facebook

Screen Lock
A1: Wait [ MS:0 Seconds:0 Minutes:10 Hours:0 Days:0 ]
A2: Lock [ Title: Code:1 Allow Cancel:Off Remember Till Off:Off Full Screen:Off Background Image: Layout:Lock ] If [ %aipackage ~ com.facebook.katana ]

Sorry for being noobish


Robert Ryan

unread,
Sep 4, 2018, 10:19:22 PM9/4/18
to tas...@googlegroups.com
You need a UI Query action between steps A1 and A2. Otherwise, %aipackage will be empty. 

Message has been deleted
Message has been deleted

Jsm

unread,
Sep 5, 2018, 6:20:43 AM9/5/18
to Tasker

Thanks a lot.Appreciate your prompt help. Finally I have got it working
Reply all
Reply to author
Forward
0 new messages