Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27353

Virtual Mouse Click

$
0
0
How do I make so that the program clicks on certain location based off of x and y coordinates that I tell it to click on? Right now I have:
Code:

mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 1)
But when it executes it clicks wherever my mouse is, regardless of what x and y coordinates I pass into it.

Here's the exact code:

Code:

For n = 0 To dt2.Rows.Count - 1

        command = dt2.Rows(n)("Command")
        pos = dt2.Rows(n)("Position")
        x = Mid(pos, 21, 4)
        y = Mid(pos, 28, 3)

        Try

            If command = "" Then

            End If

            If command = "Double Click" Then
                mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 1)
                mouse_event(MOUSEEVENTF_RIGHTUP, x, y, 0, 1)

            End If

            If command = "Left Click" Then
                mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 1)

            End If

            If command = "Right Click" Then
                mouse_event(MOUSEEVENTF_RIGHTDOWN, x, y, 0, 1)

            End If

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    Next


dt2 is a datatable

Viewing all articles
Browse latest Browse all 27353

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>