我有一个程序可以随机设置 x,y 坐标然后单击的光标。我有这个函数/子,它根据某些参数创建一个矩形。
Private Sub drawTitleBarRectangle()
Dim titleBarRectangle As Rectangle = RectangleToScreen(Me.ClientRectangle)
Dim titleBarRectangleHeight As Integer = titleBarRectangle.Top - Me.Top
Dim titleBarRectangleWidth As Integer = Screen.PrimaryScreen.Bounds.Width
Dim titleBarRectangleTop As Integer = Screen.PrimaryScreen.Bounds.Top
Dim titleBarBounds As New Drawing.Rectangle(0, 0, titleBarRectangleWidth, titleBarRectangleHeight)
End Sub
我想检查光标何时位于 x,y 位置,是否在从该函数创建的矩形的边界内。现在我有这个:
drawTitleBarRectangle()
SetCursorPos(x, y)
If titleBarRectangle.Contains(x, y) Then
leftClick(800, 800)
End If
这Private titleBarRectangle
是来自我声明的一个全局变量,因为Private titleBarRectangle As New Drawing.Rectangle
我不太清楚为什么它在那里老实说......
任何帮助,将不胜感激。