Remember, this returns the coordinates of the color in a window, not the position on the screen, you'll have to use GetWindowRect to get the rect and add the needed numbers to the coordinates for the position on the screen.
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Function FindColor(Color As Long, X1 As Long, Y1 As Long, X2 As Long, Y2 As Long, _
Window As Long) As POINTAPI
Dim xx As Long, yy As Long, TestDC As Long, WndRECT As RECT, temp As POINTAPI
TestDC = GetDC(Window)
For yy = Y1 To Y2
For xx = X1 To X2
If GetPixel(TestDC, xx, yy) = Color Then
temp.X = xx
temp.Y = yy
FindColor = temp
Exit Function
End If
DoEvents
Next xx
Next yy
FindColor.X = -1
FindColor.Y = -1
End Function
Enjoy :cool: