
terrankiller
Veteran

Jan 2, 2006, 4:41 AM
Post #2 of 17
(494 views)
Shortcut
|
|
Re: [brownhead] I'm trying to figure out how to locate a color on the users screen, can anybody help?
[In reply to]
|
Can't Post
|
|
You can use Cruel Machines findcolorspiral function: http://www.cruels.net/viewtopic.php?t=176 You can use this function as well: Private Function ColorSearch(color, x1, y1, x2, y2 As Long) As POINTAPI Dim x As Long, y As Long, xy As String Dim StrTemp As String, XYarr(0 To 1) As String For x = x1 To x2 For y = y1 To y2 XYarr(0) = x XYarr(1) = y If GetPixel(SelWnd,x, y) = color Then ColorSearch.x = x ColorSearch.y = y Exit Function End If Next y Next x End Function Or use this one.: Public Function FindColor(window As Long, ColorToFind As Long) Dim x As Long, y As Long, Test As Long, WndRECT As RECT GetWindowRect window, WndRECT Test = GetDC(window) For y = 0 To (WndRECT.Bottom - WndRECT.Top) For x = 0 To (WndRECT.Right - WndRECT.Left) If GetPixel(Test, x, y) = ColorToFind Then SetCursorPos x + WndRECT.Left, y + WndRECT.Top Exit Function End If Next x Next y End Function Declarations: Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type
|