Results 1 to 4 of 4

Thread: Get mouse position [Solved]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    169

    Thumbs up Get mouse position [Solved]

    How do I get the position of the mouse on the whole screen.
    Last edited by nuclear112; Aug 3rd, 2007 at 12:53 AM.

  2. #2
    Addicted Member Jazz00006's Avatar
    Join Date
    Feb 2006
    Posts
    185

    Re: Get mouse position

    Code:
    Private Type POINTAPI
        X As Long
        Y As Long
    End Type
    
    Private Declare Function GetCursorPos Lib "user32" _
    (lpPoint As POINTAPI) As Long

    Code:
    Dim MousePos as POINTAPI
    GetCursorPos MousePos
    label1.caption = MousePos.x & ", " & MousePos.y

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    169

    Re: Get mouse position

    Thanks.
    Last edited by nuclear112; Aug 3rd, 2007 at 12:52 AM.

  4. #4
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: Get mouse position

    vb Code:
    1. Private Declare Sub GetCursorPos Lib "User32" (lpPoint As POINTAPI)
    2.  
    3. Private Type POINTAPI
    4.      x As Long
    5.      y As Long
    6. End Type
    7.  
    8. Private Sub Form_Load()
    9.       Timer1.Enabled = True
    10.       Timer1.Interval = 50
    11. End Sub
    12.  
    13. Private Sub Timer1_Timer()
    14.     Dim Rect As POINTAPI
    15.     GetCursorPos Rect
    16.     Label1.Caption = "X = " & Rect.x
    17.     Label2.Caption = "Y = " & Rect.y
    18. End Sub

    Use this with a timer to get it.

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