Author Topic: Get mouse coordinates Acad 2k8  (Read 950 times)

0 Members and 1 Guest are viewing this topic.

migliosa

  • Guest
Get mouse coordinates Acad 2k8
« on: August 16, 2007, 09:02:48 AM »
Hi,

is there any way to get mouse coord. on 2k8 ?
So far, I used mousetracker.dll but I was not able to find a new release.

thanks a lot
sandro

Bryco

  • Water Moccasin
  • Posts: 1850
Re: Get mouse coordinates Acad 2k8
« Reply #1 on: August 16, 2007, 11:05:43 PM »
There's a couple of Apis you might look at. The below sub adds points but in the opposite direction.
Code: [Select]
Declare Function SetCursorPos& Lib "user32" (ByVal X As Long, ByVal Y As Long)

Type POINTAPI
    X As Long
    Y As Long
End Type
Declare Function GetCursorPos Lib "user32.dll" (ByRef lpPoint As POINTAPI) As Long

Private Declare Sub sapiSleep Lib "kernel32" _
        Alias "Sleep" _
        (ByVal dwMilliseconds As Long)


Sub XC()
    Dim i As Integer
    Dim Pt As AcadPoint
    Dim P(2) As Double
    For i = 1 To 5
        sapiSleep (500)
        Dim cpos As POINTAPI
        GetCursorPos cpos
        P(0) = cpos.X: P(1) = cpos.Y
        Set Pt = ThisDrawing.ModelSpace.AddPoint(P)
        Pt.Update
    Next
End Sub