|
Post by Admin on Jun 21, 2014 21:01:00 GMT
The following code demonstrates how to wait for a pixel to change color or time out.
$nX = 10 $nY = 10
;Get a color and pass it to function $Color = PixelGetColor($nX, $nY)
;Wait for color to change or time out after 5 seconds. $NewColor = _ColorWaitChanged($nX, $nY, $Color, 5000) If @error Then MsgBox(0, "Error: " & @error, "Color did not change") Exit EndIf
MsgBox(0, "Success", "Color changed to 0x" & Hex($NewColor, 6))
;########################################################################### ;Waits for passed color at the given co-ordinates to to change or time out. ;########################################################################### Func _ColorWaitChanged($x, $y, $col = 0, $timeout = 0, $sleep = 100) Local $Timer If $timeout Then $Timer = TimerInit() EndIf Do If $timeout Then If TimerDiff($Timer) >= $timeout Then Return SetError(1, 0, 0) EndIf EndIf Sleep($sleep) Until (PixelGetColor($x, $y) <> $col) Return PixelGetColor($x, $y) EndFunc ;==>_ColorWaitChanged
|
|