Set a delay between macros

dhj49er

Well-known member
When I have two triggers for the same macro creates bugs that's why I want to put a delay between the use of my Macro
I think it depends on what you want to happen.
Do you want the macro to run completely on the first trigger and ignore the second trigger if it occurs whilst the macro is running?
Or wait for the macro to complete before running it again if the 2nd trigger has fired? In which case
I would use a boolean variable as a flag to show the macro is running. Something like the following. The boolean variable is MacroCompleted, set to false whilst the macro is ruining and set to true at the end of the macro.
T Trigger 1
T Trigger 2
A If Trigger 1
Wait MacroCompleted is True - Constraint MacroCompleted is False
A Else If Trigger 2
Wait MacroCompleted is True - Constraint MacroCompleted is False
A End if
A Set variable MacroCompleted False
(Other actions)
A Set variable MacroCompleted True

For the first use case above, the macro would look something like
T Trigger 1 - Constraint MacroCompleted True
T Trigger 2 - Constraint MacroCompleted True
A Set MacroCompleted False
(Other actions)
A Set MacroCompleted True
 
Je pense que cela dépend de ce que vous voulez qu'il se passe.
Voulez-vous que la macro s'exécute complètement sur le premier déclencheur et ignore le deuxième déclencheur s'il se produit pendant l'exécution de la macro ?
Ou attendez que la macro se termine avant de l'exécuter à nouveau si le 2e déclencheur s'est déclenché ? Dans quel cas
J'utiliserais une variable booléenne comme indicateur pour montrer que la macro est en cours d'exécution. Quelque chose comme ce qui suit. La variable booléenne est MacroCompleted, définie sur false pendant que la macro est ruinée et définie sur true à la fin de la macro.
T Déclencheur 1
T Déclencheur 2
A Si déclencheur 1
Attendez que MacroCompleted est vrai - La contrainte MacroCompleted est fausse
A Sinon si déclencheur 2
Attendez que MacroCompleted est vrai - La contrainte MacroCompleted est fausse
A Fin si
A Set variable MacroCompleted False
(D'autres actions)
A Définir la variable MacroCompleted True

Pour le premier cas d'utilisation ci-dessus, la macro ressemblerait à quelque chose comme
T Déclencheur 1 - Contrainte MacroTerminé Vrai
T Déclencheur 2 - Contrainte MacroTerminé Vrai
A Set MacroCompleted False
(D'autres actions)
A Set MacroCompleted True
 

Attachments

  • Screenshot_20221114-094413_MacroDroid.jpg
    Screenshot_20221114-094413_MacroDroid.jpg
    283.8 KB · Views: 7
I think it depends on what you want to happen.
Do you want the macro to run completely on the first trigger and ignore the second trigger if it occurs whilst the macro is running?
Or wait for the macro to complete before running it again if the 2nd trigger has fired? In which case
I would use a boolean variable as a flag to show the macro is running. Something like the following. The boolean variable is MacroCompleted, set to false whilst the macro is ruining and set to true at the end of the macro.
T Trigger 1
T Trigger 2
A If Trigger 1
Wait MacroCompleted is True - Constraint MacroCompleted is False
A Else If Trigger 2
Wait MacroCompleted is True - Constraint MacroCompleted is False
A End if
A Set variable MacroCompleted False
(Other actions)
A Set variable MacroCompleted True

For the first use case above, the macro would look something like
T Trigger 1 - Constraint MacroCompleted True
T Trigger 2 - Constraint MacroCompleted True
A Set MacroCompleted False
(Other actions)
A Set MacroCompleted True
Screenshot_20221114-094413_MacroDroid.jpg
 
I have achieved something similar using a boolean value ...
On trigger for my first action I set a boolean like:
Cool_Macro_initiated = true
Then at the end
Set the last action to update the boolean to: false.

Now If you include
Cool_macro_initiated =false
As a constraint then you will not have collisions from multiple triggers.
 
Top