In the script replace the function checkMainScreen() to:
[code=autoit]
Func checkMainScreen() ;Checks if in main screen
_CaptureRegion()
If _ColorCheckVariation(_PixelGetColor_GetPixel(284, 28), Hex(0x41B1CD, 6), 20) = False Then
While 1
_CaptureRegion()
SetLog("Trying to get to main screen")
If _ColorCheckVariation(_PixelGetColor_GetPixel(458, 311), Hex(0x33B5E5, 6), 20) Then ;Check for out of sync or inactivity
Click(416, 399)
Else
WinActive("BlueStacks App Player")
Click(126, 700)
Local $RunApp = StringReplace(_WinAPI_GetProcessFileName(WinGetProcess("BlueStacks App Player")), "Frontend", "RunApp")
Run($RunApp & " Android com.supercell.clashofclans com.supercell.clashofclans.GameApp")
EndIf
If _Sleep(5000) or $RunState = False Then ExitLoop
Local $counter = 0
While 1
If _Sleep(2000) or $RunState = False Then ExitLoop(2)
If WinExists("BlueStacks App Player") Then
_CaptureRegion()
If _ColorCheckVariation(_PixelGetColor_GetPixel(235, 209), Hex(0x9E3826, 6), 20) Then Click(429, 493);See if village was attacked, clicks Okay
If _ColorCheckVariation(_PixelGetColor_GetPixel(284, 28), Hex(0x215B69, 6), 20) Then Click(1, 1) ;Click away If things are open
If _ColorCheckVariation(_PixelGetColor_GetPixel(819, 55), Hex(0xD80400, 6), 20) Then Click(819, 55) ;Clicks X
If _ColorCheckVariation(_PixelGetColor_GetPixel(331, 330), Hex(0xF0A03B, 6), 20) Then Click(331, 330) ;Clicks chat thing
If _ColorCheckVariation(_PixelGetColor_GetPixel(284, 28), Hex(0x41B1CD, 6), 20) Then ;In main screen
Exitloop(2)
EndIf
EndIf
$counter += 1
If $counter >= 150 Then ;Five minutes
SetLog("Could not automatically load Clash Of Clans")
If _Sleep(1000) or $RunState = False Then ExitLoop(2)
SetLog("Restarting BlueStacks")
WinActive("BlueStacks App Player")
Local $RunApp = StringReplace(_WinAPI_GetProcessFileName(WinGetProcess("BlueStacks App Player")), "Frontend", "RunApp")
ProcessClose("HD-Frontend.exe")
If _Sleep(5000) or $RunState = False Then ExitLoop(2)
Run($RunApp & " Android com.supercell.clashofclans com.supercell.clashofclans.GameApp")
Do
If _Sleep(10000) or $RunState = False Then ExitLoop(2)
Until ControlGetHandle("BlueStacks App Player", "", "BlueStacksApp1") <> 0
checkMainScreen()
ExitLoop(2)
EndIf
WEnd
WEnd
EndIf
EndFunc
[/code]