I'm trying to make a function based from MasterFocus' "WaitPixelColor" and I am wondering if there is a way to simplify this.

Code: Select all

```
WaitPixelColor(p_DesiredColor,p_PosX,p_PosY,p_TimeOut=0,p_GetMode="",p_ReturnColor=0) {
l_Start := A_TickCount
Loop {
PixelGetColor, l_OutputColor, %p_PosX%, %p_PosY%, %p_GetMode%
If ( ErrorLevel )
PixelGetColor, l_OutputColor, %p_PosX%+2, %p_PosY%, %p_GetMode%
If ( ErrorLevel )
PixelGetColor, l_OutputColor, %p_PosX%+4, %p_PosY%, %p_GetMode%
If ( ErrorLevel )
PixelGetColor, l_OutputColor, %p_PosX%+6, %p_PosY%, %p_GetMode%
If ( ErrorLevel )
PixelGetColor, l_OutputColor, %p_PosX%+8, %p_PosY%, %p_GetMode%
If ( ErrorLevel )
PixelGetColor, l_OutputColor, %p_PosX%+10, %p_PosY%, %p_GetMode%
If ( ErrorLevel )
Return ( p_ReturnColor ? l_OutputColor : 1 )
If ( l_OutputColor = p_DesiredColor )
Return ( p_ReturnColor ? l_OutputColor : 0 )
If ( p_TimeOut ) && ( A_TickCount - l_Start >= p_TimeOut )
Return ( p_ReturnColor ? l_OutputColor : 2 )
}
}
```