无法运行“移动光标宏”

时间:2019-10-03 08:52:59

标签: vba

因此,我发现此代码每分钟移动一次光标。它可以运行,但是一分钟后我收到错误消息:

  

检测到歧义名称:移动光标。

我在做什么错了?

Private dtmNext As Date

Private Type POINTAPI
    x As Long
    y As Long
End Type

Private Declare Function GetCursorPos Lib "user32" (Point As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Integer, ByVal y As Integer) As Long

Sub Move_Cursor()
    Dim Hold As POINTAPI
    GetCursorPos Hold
    SetCursorPos Hold.x + 30, Hold.y
    dtmNext = DateAdd("n", 1, Now)
    Application.OnTime dtmNext, "Move_Cursor"
End Sub

Sub Stop_Cursor()
    Application.OnTime dtmNext, "Move_Cursor", , False
End Sub

0 个答案:

没有答案