The macro records the Y mouse position in a cell then moves down one cell and records the next mouse position. There is a 100 milli second delay between recordings. It works but only when mouse movements are not continuous.
The full code further below is mostly declarations. The actual recording of the mouse is done by:
Code: Select all
GetCursorPos lngCurPos REM gets the mouse from Windows
CellRange.value = lngCurPos.y REM places the Y position in a cell.
Code: Select all
REM ***** BASIC *****
Option Explicit
Declare Sub Sleep Lib "C:\WINDOWS\system32\kernel32.dll" Alias "Sleep" ( ByVal dwMilliseconds As Long)
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Type POINTAPI
x As Long
y As Long
End Type
Sub LogYMousePosition()
Dim lngCurPos As POINTAPI
Dim Doc As Object
Dim Sheet As Object
Dim CellRange As Object
Dim i as Long
i=1
Doc = ThisComponent
Sheet = Doc.Sheets.getByName("Sheet1")
CellRange = Sheet.getCellByPosition(0,i)
Do
GetCursorPos lngCurPos
CellRange.value = lngCurPos.y
i=i+1
CellRange = Sheet.getCellByPosition(1,i)
Sleep 100
if i=70 then i=0 rem for testing only
Loop
End Sub