Im not a programmer, just a regular dude but I made this to help me farm coins. Its not very good and has limitations but it works, if anyone else knows how to improve this please do. I use autohotkey for the macro.
!q::
Sleep, 3000
IfWinActive, Magic Origins, , WinActivate, Magic Origins,
{...