Multiple triggers

HappyDev

New member
Hi @MacroDroidDev
My macro gets triggered when an app is launched, but instead of launching app one time, and when app is foreground, macro gets triggered many times (example when you reply in floating to another app or click floating button of any other app etc.)
What's the best way to prevent that
 

Dm114

Well-known member
Hi @MacroDroidDev
My macro gets triggered when an app is launched, but instead of launching app one time, and when app is foreground, macro gets triggered many times (example when you reply in floating to another app or click floating button of any other app etc.)
What's the best way to prevent that
This trigger fires every time an app comes to foreground i.e. when launched and then every time you go back to it after replying to another one...
 

dhj49er

Well-known member
What's the solution?
I think that may depend on what the macro is intended to do, just once when the app is launched.
One approach, without knowing the above, is to set a boolean variable when the macro runs and use the opposite state of this variable as a constraint for the macro. The macro will only run once and you'll need another macro that resets this variable, either manually invoked or via a suitable trigger.
 

Dm114

Well-known member
I think that may depend on what the macro is intended to do, just once when the app is launched.
One approach, without knowing the above, is to set a boolean variable when the macro runs and use the opposite state of this variable as a constraint for the macro. The macro will only run once and you'll need another macro that resets this variable, either manually invoked or via a suitable trigger.
The problem will be how or when to toggle this boolean variable when apps are really "closed"? 🤔
 

Xyphes

New member
I didn't really understand the problem but maybe you can put a constraint like "application is running"
Or an if clause?
 

dhj49er

Well-known member
I didn't really understand the problem but maybe you can put a constraint like "application is running"
Or an if clause?
Unfortunately, the op hasn't provided details of his macro, it's triggered on an launch but I don't know anymore details.
I think if the op could provide the macro, other ideas, such as yours, might be the solution.
 

Snurre

Well-known member
Unfortunately, the op hasn't provided details of his macro, it's triggered on an launch but I don't know anymore details.
I think if the op could provide the macro, other ideas, such as yours, might be the solution.
Yeah, a screenshot could also help
 
D

Deleted member 9002

Guest
Just a simple macro
T: app launched
A: pop up message
 

RSF

Well-known member
@HappyDev - If you're mostly concerned with transitory interruptions to using an app, like responding to pop-ups from other apps, you could also do a time-based approach, similar to what @dhj49er suggested with the boolean variable but using a stopwatch to ignore interruptions in the foreground usage of an app less than some number of seconds ... that way, if you respond to another app's pop-up, but quickly return to the app in question, it won't be treated as opened from scratch. Something like so, using a MacroDroid stopwatch called "App inactive timer":
Screenshot_20220602-191402.png
It starts a stopwatch anytime an app loses foreground focus, and when the app comes back to foreground, only does actions if it's over a minute since it left foreground...
 
Top