How to show and move the mouse cursor in Powerpoint VBA?

I searched this many times and it seems unbelievable that there was no answer. Does anyone know how to do this?

+3
source share
1 answer

The show cursor part is part of PowerPoint β€” part of the movement must come from an API call. Here you are:

Public Declare Function SetCursorPos Lib "user32.dll" (ByVal X As Long, ByVal Y As Long) As Long
//'USE THIS IF x64: Public Declare PtrSafe Function SetCursorPos Lib "user32.dll" (ByVal X As Long, ByVal Y As Long) As LongPtr
Public Type POINTAPI
    X As Long
    Y As Long
End Type
Sub ShowCursorAndMove()
    Dim currView As SlideShowView
    Set currView = ActivePresentation.SlideShowSettings.Run.View
    currView.PointerType = ppSlideShowPointerArrow
    MoveMouse 400, 300
End Sub
Sub MoveMouse(X As Single, Y As Single)
    Dim pt As POINTAPI
    pt.X = X
    pt.Y = Y
    SetCursorPos pt.X, pt.Y
End Sub
+5
source

Source: https://habr.com/ru/post/1748609/


All Articles