Darthatron
Massive Troll
Alright, this is a VERY SIMPLE find pixel color function. It is slow and shiet, but hey, whatever floats your boat.
Add this to General Declarations...
To actually get the pixel you want to look for use this code... Put it in an Image_MouseUp or something.
This is the Function that will search the screen for that Pixel Color...
You could edit that code to return the values of the X and Y values if you know how. Use it well.
Add this to General Declarations...
Code:
Option Explicit
Private Type PointApi
X As Long
Y As Long
End Type
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As PointApi) As Long
Private Declare Function SetCursorPos Lib "user32.dll" (ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Dim PosXY As PointApi
Dim Retval As Long
Dim tPosXY As PointApi
Dim sTemp As String
Dim lColor As Long
Dim lDC As Long
Dim iX, iY As Integer
Dim ColorPixel As Long
To actually get the pixel you want to look for use this code... Put it in an Image_MouseUp or something.
Code:
lDC = GetWindowDC(0)
Call GetCursorPos(tPosXY)
lColor = GetPixel(lDC, tPosXY.X, tPosXY.Y)
Picture1.BackColor = lColor
This is the Function that will search the screen for that Pixel Color...
Code:
Function FindPixelColor(Color As Long)
If Color > -1 And Color < 16777216 Then 'Checks if the Color is a Color or not.
For iY = 0 To Screen.Height 'Gets the screens height.
For iX = 0 To Screen.Width 'Gets the screens width.
ColorPixel = GetPixel(lDC, iX, iY) 'Gets the pixel color at location.
If Color = ColorPixel Then 'Checks if the colors match.
SetCursorPos Val(iX), Val(iY) 'Change this to a MoveMouseSmooth function, or whatever...
Exit Function 'Exits the Function.
End If
Next iX 'Tries the next X location.
Next iY 'Starts again at the next Y location.
MsgBox "The color was not found.", vbOKOnly, "Error."
Else
MsgBox "That color is invalid.", vbOKOnly, "Error."
End If
End Function
You could edit that code to return the values of the X and Y values if you know how. Use it well.

