Windows Forms Cursor positon not working


  • Public Class Form1
        Declare Sub mouse_event Lib "user64" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        End Sub
        Private Sub MyMethod()
            WindowsForms.Cursor.Position = New System.Drawing.Point(Windows.Forms.Cursor.Position)
            mouse_event(&H2, 0, 0, 0, 1) 'cursor will go down (like a click)
            mouse_event(&H4, 0, 0, 0, 1) ' cursor goes up again
        End Sub
    End Class

    does anyone know why it says windowsforms is not declared it may be unaccessible due to its protection level

    Tuesday, March 14, 2017 2:59 PM


  • Hi

    Probably because it is not declared or it is inaccessible!

    Try using just

    without the WindowsForms.

    Regards Les, Livingston, Scotland

    • Edited by leshay Tuesday, March 14, 2017 3:07 PM
    • Marked as answer by xXNebulaNinjaXx Tuesday, March 14, 2017 3:16 PM
    Tuesday, March 14, 2017 3:05 PM

All replies