' MODULE... ' ========= Option Explicit Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Public Declare Function GetForegroundWindow Lib "user32" () As Long Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long) Public Declare Function GetCursorPos Lib "user32" (lpPoint As Point) As Long Public Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long Public Const MOUSEEVENTF_LEFTDOWN = &H2 Public Type Point X As Long Y As Long End Type: ' FORM... ' ======= Option Explicit Dim ProcessHandle As Long, ProcessDC As Long Private Sub Form_Activate() ProcessHandle = FindWindow(vbNullString, "Window Name Here") ProcessDC = GetDC(0) End Sub Private Sub Form_Unload(Cancel As Integer) Call ReleaseDC(0, ProcessDC) End Sub Private Sub Timer1_Timer() On Error Resume Next Dim X As Long, Y As Long, PixelColor As Long Dim CursorPosition As Point If (ProcessHandle <> GetForegroundWindow()) Then Exit Sub End If Call GetCursorPos(CursorPosition) For X = CursorPosition.X - 20 To CursorPosition.X + 20 For Y = CursorPosition.Y - 20 To CursorPosition.Y + 20 PixelColor = GetPixel(ProcessDC, X, Y) 'Replace RGB value for your specified color If (PixelColor = RGB(255, 255, 255)) Then Call mouse_event(MOUSEEVENTF_LEFTDOWN, CursorPosition.X, CursorPosition.Y, 0, 0) Exit Sub End If Next Y Next X End Sub

