Results 1 to 2 of 2

Thread: Mouse wont move

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2009
    Posts
    435

    Mouse wont move

    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
    Last edited by werido; Oct 9th, 2009 at 07:09 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width