Im trying to get my mouse to move to the color Red on a webpage, and its not working. The timer is started, and nothing happens. "Web Diner's Hexcode Color Chart" is the name of the website that im using to move mouse to red.
Code:Dim ProcessHandle As Long, ProcessDC As Long Private Sub Form_Unload(ByVal Cancel As Integer) Call ReleaseDC(0, ProcessDC) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ProcessHandle = FindWindow(vbNullString, "Web Diner's Hexcode Color Chart") ProcessDC = GetDC(0) End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick 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) If (PixelColor = RGB(255, 0, 0)) Then mouse_event(MOUSEEVENTF_LEFTDOWN, CursorPosition.X, CursorPosition.Y, 0, 0) Exit Sub End If Next Y Next X End Sub


Reply With Quote