Simple clicking macro loop failing randomly

Good day, thank you for taking the time to view my post.

I've put together a simple looping macro that clicks on specific areas of the screen (couldn't get "identify in app" to work; never got the popup or whatever). Anyways, the clicking works fine, it works as intended without issues except when it randomly stops working. Problematically, I'm trying to get it to run overnight but it fails on average after about 4 hours, although this varies quite a bit. Each full loop lasts approximately 20 seconds. Within the main loop, there are nested loops which last about 1.5 seconds.

Steps I have taken to resolve the issue unsuccessfully (done all together):
- Airplane mode the phone so no distractions on screen
- Restarting the phone before overnight use
- Increasing wait times; now shortest wait is 100 ms.

My device is a Pixel 6a build UQ1A.231205.015

Please find attached my macro. I can't get the file to open on PC but here's the gist of it:

Trigger: on screen button
Loop{
while (volume < 8%){
wait 1700
click
wait 500
click
wait 500
click
wait 500
loop(10){
click
wait 100
}
}
}
No constraint
etc.... It's a pretty simple script really and works great... until it just doesn't.

Thank you again for your time in this matter. Have a great day :)
 

Attachments

  • Game macro.macro
    15.4 KB · Views: 4

dhj49er

Well-known member
Is it a game that is running when you start this macro?

If so, does the game stop working at all during your testing?

Have you disabled all battery saving options for MD, MD helper and the app/game?

When you say the macro stops working, what is it that stops working?

What's in the MD system log when the macro stops working?

Does the app/game run overnight, without stopping, if the macro is not run? Or is the macro necessary to keep the app/game running?
 
Thank you for taking your time to respond, it's must appreciated :)

I'll try disabling all battery saving options as well as catch the log when it fails next and will report back.

Is it a game that is running when you start this macro? Yes

If so, does the game stop working at all during your testing? No, the game has never crashed or stopped

Have you disabled all battery saving options for MD, MD helper and the app/game? I have not, but I will try this. The phone is plugged in the entire time so I never considered this but it's worth a shot.

When you say the macro stops working, what is it that stops working? The macro stops at the start of the main loop and doesn't click anything anymore.

What's in the MD system log when the macro stops working? I didn't realize the log only went back so far. I'll check it next time it fails as my current log doesn't include the last failure unfortunately :(

Does the app/game run overnight, without stopping, if the macro is not run? Or is the macro necessary to keep the app/game running? The app runs fine overnight even after the macro seizes.b
 

hsurB

Well-known member
I use some clicking macros overnight and I'd recommend two things:
1. Reseting the app that macro perform clicks in few times during night if its possible.
2. Maybe another macro that disables/enables main macro for short period of time
 
I use some clicking macros overnight and I'd recommend two things:
1. Reseting the app that macro perform clicks in few times during night if its possible.
2. Maybe another macro that disables/enables main macro for short period of time
Thanks for the advice! I never thought about approaching it from this perspective but I could see how this could work. Programming a macro to to reset the app and the macro at 2 hour intervals or so would definitely be a great stop gap while I figure out why it keeps hanging.
 

hsurB

Well-known member
My guess is - its actually phone that randomly lags for a second or so. Even tho phone lagged only for a second it could be that click was registred as already done, it went to the next action which is wait 500ms but this action doesn't really wait 500 ms but sets next action to be performed at 500ms from the time last action was done (please correct me if I am wrong here)
It causes phone to do few things at the time when it started working again and even though your macro might look simple - its loop or even as you said loops inside a loop and a lot of wait before next action actions and it could easily break.
Longer delay would solve it I guess but that defeats the purpose if you could just restart the macro/app (or even both) what will take few seconds each few hours to solve possible problems.
 
My guess is - its actually phone that randomly lags for a second or so. Even tho phone lagged only for a second it could be that click was registred as already done, it went to the next action which is wait 500ms but this action doesn't really wait 500 ms but sets next action to be performed at 500ms from the time last action was done (please correct me if I am wrong here)
It causes phone to do few things at the time when it started working again and even though your macro might look simple - its loop or even as you said loops inside a loop and a lot of wait before next action actions and it could easily break.
Longer delay would solve it I guess but that defeats the purpose if you could just restart the macro/app (or even both) what will take few seconds each few hours to solve possible problems.
Hey, thanks for the input! I could always try longer waits, up to a point. With the shortest one being 100ms, I could increase up to perhaps 200ms, but like you say restarting the app and macro periodically might be the simplest way forward. I'm very new to macrodroid but it does seem like it would be very easy to develop what you suggest.

Edit: Looks like starting the app requires root access, which the device doesn't have :/ Restarting the macro itself though should be alright. What about in lieu of a main loop, I have a separate macro that restarts it every 20 seconds? Do you think this would work? I guess that macro's loop could always fail

Edit 2: Ok I'm now using a two macro setup; one master control macro which enables, runs, and disables the action macro on a loop. So far so good, it's working just as well as it did without the control macro. I'll report back on how stable it is!

Thanks again for your input, it's very appreciated :) Have a great day.
 
Last edited:

hsurB

Well-known member
Check launch app action. When configuring select force new. It shouldn't require root since I don't have it and use it. To kill/force stop app you need root and enabling/disabling(maybe thats what you saw) but forcing phone to open new works just fine.
Personally I'd use other macro that will restart your main one each 30min/1h.

I'd use daytime trigger for it.
Few triggers for different hours.

Triggers:
1. Every day 0:00
2. Every day 1:00
3. Every day 2:00
...
Actions:
Cancel macro actions (your main one) just in case.
Disable macro - main one.
Launch app - your app - force new.
Either wait before next actions - like 5s to make sure it opened or at some point when you are more advanced try wait until trigger action - app launched your app, and then wait before with shorter delay.
Enable your main macro
Run macro - your main macro
 
Last edited:
Check launch app action. When configuring select force new. It shouldn't require root since I don't have it and use it. To kill/force stop app you need root and enabling/disabling(maybe thats what you saw) but forcing phone to open new works just fine.
Personally I'd use other macro that will restart your main one each 30min/1h.

I'd use daytime trigger for it.
Few triggers for different hours.

Triggers:
1. Every day 0:00
2. Every day 1:00
3. Every day 2:00
...
Actions:
Cancel macro actions (your main one) just in case.
Disable macro - main one.
Launch app - your app - force new.
Either wait before next actions - like 5s to make sure it opened or at some point when you are more advanced try wait until trigger action - app launched your app, and then wait before with shorter delay.
Enable your main macro
Run macro - your main macro
Thanks again for your input, it's much appreciated!
I'll definitely try this out if my current setup fails tonight. I'll keep you posted!

Cheers

-----------------
Update 1:

Macro survived the night (6 hrs). Will keep testing for stability and post updates.

For future users with this issue, the current setup I am using involves the original macro with the main loop removed, and a second macro on a loop which activates, triggers, waits 20 seconds, then deactivates the action macro. This replaces the single macro with a main loop which would fail randomly overnight, lasting on average maybe 4 hours.

-----------------
Update 2:

Macro survived the night again. So far, this change has made it completely stable. Around 20 hrs of uptime without a hitch. Will update again.

-----------------
Update 3:

No issues after a third night. I'll update if I run into issues, otherwise this seems resolved.
 
Last edited:
Top