VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Get Screen Mouse Coordinates (Simplified)

by Aimee Bailey (11 Submissions)
Category: Graphics
Compatability: VB Script
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

See code name.

Rate Get Screen Mouse Coordinates (Simplified)

'Hide the following code in a module someware!
Private Declare Function GetCursorPos Lib _
  "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
  x As Long
  y As Long
End Type
'------------------------------
Public Function GetPos(Optional x As Single _
  = 0, Optional y As Single = 0)
Dim Pos As POINTAPI
Dim retVal As Boolean
 retVal = GetCursorPos(Pos)
 x = Pos.x
 y = Pos.y
End Function
' Put the following into the form of your
' choice and then create a timer called
' 'Timer1' and remember to set the interval
' to something like '10'
'-----------------------------
Private Sub Timer1_Timer()
Dim x As Single
Dim y As Single
 GetPos x, y
 Me.Caption = x & "x" & y
End Sub

Download this snippet    Add to My Saved Code

Get Screen Mouse Coordinates (Simplified) Comments

No comments have been posted about Get Screen Mouse Coordinates (Simplified). Why not be the first to post a comment about Get Screen Mouse Coordinates (Simplified).

Post your comment

Subject:
Message:
0/1000 characters