1.Delete every thing before the first line containing Send.
2.Add instead:
WinWait("","")
If Not WinActive("","") Then WinActivate("","")
WinWaitActive("","")
3.Replace every _WinWaitActivate with WinWaitActive
2.Add instead:
WinWait("","")
If Not WinActive("","") Then WinActivate("","")
WinWaitActive("","")
3.Replace every _WinWaitActivate with WinWaitActive