IsCursorInArea

This function returns a boolean value according to whether the cursor is in an area or not.

VB.NET

''' <summary>
''' Checks if the Cursor is in an area.
''' </summary>
''' <param name="minX">The Minimum X Value</param>
''' <param name="minY">The Minimum Y Value</param>
''' <param name="maxX">The Maximum X Value</param>
''' <param name="maxY">The Maximum Y Value</param>
''' <returns>True if it is inside the area, False otherwise.</returns>
''' <remarks></remarks>

Public Function isCursorInArea(ByRef minX As Integer, ByRef minY As Integer, _
ByRef maxX As Integer, ByRef maxY As Integer)
    If Windows.Forms.Cursor.Position.X >= minX And Windows.Forms.Cursor.Position.Y >= minY _
    And Windows.Forms.Cursor.Position.X <= maxX And Windows.Forms.Cursor.Position.Y <= maxY Then
        Return True
    End If
    Return False
End Function

' Example usage:
If isCursorInArea(0, 0, 50, 50) Then
    MessageBox.Show("Cursor is in area")
End If

See Also

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License