[RESOLVED] Get mouse position for compare
Hi,
I'm using the mouse_event API to move the mouse.
If we say that the mouse first is at one point and this point is stored into a variable.
After that, I'll move the mouse a bit to the right.
Then the mouse_event code moves the mouse 100 to the right.
Now, I want to get the mouse position again and then be able to get a number of how much I've moved the mouse.
I know you can use the MouseMove code event to get the position of the mouse. My problem is that 100 in the mouse_event doesn't seem to be 100 in MouseMove.
So, does anyone know how to do this?
Re: Get mouse position for compare
If you need to get precise position of your mouse pointer then search forum for GetCursorPos api function - there are tons of samples posted.
Re: Get mouse position for compare
okay, but do the GetCursorPos use the same measurement? Is 100 the same distance in mouse_event as in GetCursorPos?
Re: Get mouse position for compare
It's always beneficial to try it yourself rather than continuously asking. ;)
To see the difference run this quick sample:
Code:
Option Explicit
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim pt As POINTAPI
GetCursorPos pt
Label1.Caption = "VB6 default: " & pt.X * Screen.TwipsPerPixelX
Label2.Caption = "API Default: " & pt.X
End Sub
But to answer your question directly - VB's default scalemode is set to Twips and APIs return Pixels so you need to convert unless you set ScaleMode to Pixels as well.