Results 1 to 2 of 2

Thread: VB - Get Cursor Position

  1. #1

    Thread Starter
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    VB - Get Cursor Position

    Add two labels (Label1 , Label2) and a timer (Timer1).

    VB Code:
    1. Option Explicit
    2.  
    3. Private Type POINTAPI 'Declare types
    4.     x As Long
    5.     y As Long
    6. End Type
    7.  
    8. Private Declare Function GetCursorPos Lib "user32" _
    9. (lpPoint As POINTAPI) As Long 'Declare API
    10.  
    11. Dim z As POINTAPI 'Declare variable
    12.  
    13. Private Sub Form_Load()
    14.  Timer1.Interval = 1
    15.  Timer1.Enabled = True
    16. End Sub
    17.  
    18. Private Sub Timer1_Timer()
    19. GetCursorPos z 'Get Co-ordinets
    20. Label1 = "x: " & z.x 'Get x co-ordinets
    21. Label2 = "y: " & z.y 'Get y co-ordinets
    22. End Sub


    Has someone helped you? Then you can Rate their helpful post.

  2. #2
    New Member
    Join Date
    May 2014
    Posts
    1

    Re: VB - Get Cursor Position

    Hey!

    How do I add the labels and a timer?

    I need to fill a vector with every coordinate that I get. How can I do that as well?

    Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width