如何在Powerpoint VBA中显示和移动鼠标光标?

时间:2010-06-04 21:57:55

标签: vba powerpoint powerpoint-vba

我对此进行了广泛的搜索,并且令人难以置信的似乎没有答案。有谁知道怎么做?

1 个答案:

答案 0 :(得分:5)

show cursor部分是PowerPoint的一部分 - 移动部分需要来自API调用。你走了:

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