Option Explicit
Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal x As LongPtr, ByVal y As LongPtr) As Long
Sub MovePointer()
Dim i As Long, j As Long
Dim x As Double, y As Double
Dim rng As Range
Application.Cursor = xlNorthwestArrow
For i = 3 To 10 Step 2
For j = 1 To 40 Step 2
Set rng = Cells(j, i)
x = ActiveWindow.PointsToScreenPixelsX(rng.Left * 96 / 72) + rng.Width / 2
y = ActiveWindow.PointsToScreenPixelsY(rng.Top * 96 / 72) + rng.Height / 2
Debug.Print rng.Address(0, 0) & ":x=" & x & ",y=" & y
SetCursorPos x, y
Application.Wait Now() + TimeValue("00:00:01")
Set rng = Nothing
Next j
Next i
Application.Cursor = xlDefault
End Sub
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme