0

如何使程序根据我告诉它单击的 x 和 y 坐标单击某个位置?现在我有:mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 1)

但是当它执行时,无论我的鼠标在哪里,它都会点击,无论我传递给它的 x 和 y 坐标是什么。

这是确切的代码:

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是一个数据表

4

1 回答 1

1

您需要先调用mouse_event以移动到 (x,y),然后再次调用以单击。或设置MOUSEEVENTF_MOVE标志以及鼠标上/下标志。

请参见此处- 您可以在一次调用中组合多个标志或进行多次调用。

于 2013-07-08T19:00:07.823 回答