Condtion: App is in foreground

Post your feature requets for new triggers, conditions, actions and other improvements.

Moderator: Martin

Locked
maddjurr
Posts: 2
Joined: 15 Apr 2014 21:15

Condtion: App is in foreground

Post by maddjurr » 15 Apr 2014 21:43

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)

User avatar
kintrupf
Posts: 257
Joined: 10 Sep 2013 08:59

Re: Condtion: App is in foreground

Post by kintrupf » 16 Apr 2014 07:18

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.

maddjurr
Posts: 2
Joined: 15 Apr 2014 21:15

Re: Condtion: App is in foreground

Post by maddjurr » 16 Apr 2014 10:29

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!

User avatar
Nerey
Posts: 102
Joined: 07 Mar 2014 16:59

Re: Condtion: App is in foreground

Post by Nerey » 16 Apr 2014 11:14

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
Sorry for bad english, my native is russian.

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

Re: Condtion: App is in foreground

Post by Martin » 17 Apr 2014 17:53

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.

Locked