Page 1 of 1

Condtion: App is in foreground

Posted: 15 Apr 2014 21:43
by maddjurr
Hi.
I want make something like this:
Open calculator (or other app without desired connection) and after using it for certain time disable WiFi and Data transmission

I want do this like this:
Trigger: App Task Started: Calculator
Action: Sleep for 10s
Condition: App is in foreground, active.
Action: Turn Off WiFi and Data transmission


Now possible options in Condition are App process running or App task running. With this options action happens even if app is in background; process isn't killed.

So I request condition: App is in foreground
It would be nice if also it will possible to choose few apps in one list (something like App Task Started)

Re: Condtion: App is in foreground

Posted: 16 Apr 2014 07:18
by kintrupf
Look at the documentation of the condition "App task running". It supplies a variable which denotes if the task is running in foreground or not:
index
the index of this task. An index of zero denotes the currently topmost running task.
So you only need to add a condition "Expression" with contents "index == 0" to check if the app runs in foreground or not.

Re: Condtion: App is in foreground

Posted: 16 Apr 2014 10:29
by maddjurr
Thank you, works like a charm, but I would never find out this by myself. It might be easier for newbies to create some graphical implementation of such features.
Nevertheless, I'm happy that my script work well now, thank you!

Re: Condtion: App is in foreground

Posted: 16 Apr 2014 11:14
by Nerey
I'm using "App task running" and Expression too
But your flow work incorrect in case if you activate Calculator, close it and open again in 10 seconds
I advice to use something like this:
1st flow
trigger: App Task Started
Action: Sleep
Action: Disable mobile data
2nd flow
trigger: App Task Ended
Action: Stop flow 1st
Or you can combine it in one flow

Re: Condtion: App is in foreground

Posted: 17 Apr 2014 17:53
by Martin
There will be a new check box available in condition App Task Running to check only for the most recent (topmost) app starting with the next version of Automagic.