【发布时间】:2018-10-16 11:29:24
【问题描述】:
我正在做一些自动化工作来重复复制粘贴工作。有时服务器会很慢。那时我会使用下面的代码等到光标等待恢复正常
Option Explicit
Private Const IDC_WAIT As Long = 32514
Private Type POINT
x As Long
y As Long
End Type
Private Type CURSORINFO
cbSize As Long
flags As Long
hCursor As Long
ptScreenPos As POINT
End Type
Private Declare Function GetCursorInfo _
Lib "user32" (ByRef pci As CURSORINFO) As Boolean
Private Declare Function LoadCursor _
Lib "user32" Alias "LoadCursorA" _
(ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
Public Function IsWaitCursor() As Boolean
' Get handle to wait cursor
Dim handleWaitCursor As Long
handleWaitCursor = LoadCursor(ByVal 0&, IDC_WAIT)
Dim pci As CURSORINFO
pci.cbSize = Len(pci)
' Retrieve information about the current cursor
Dim ret As Boolean
ret = GetCursorInfo(pci)
If ret = False Then
MsgBox "GetCursorInfo failed", vbCritical
Exit Function
End If
' Returns true when current cursor equals to wait cursor
IsWaitCursor = (pci.hCursor = handleWaitCursor)
End Function
以上代码在 MS Excel 2013 32 位中对我来说运行良好。但现在我使用的是 MS Excel 64 位,上面的代码不起作用。有人请告诉我需要做什么
【问题讨论】:
-
当你说:code is not working,是不是抛出了错误?还是不等待?
-
也可能有帮助 - 引用:“LongPtr 是您的 Declare 语句中任何指针或句柄的完美类型。...不要忘记一个非常重要的细节:不仅是您的 @987654324 @ 语句应该使用
LongPtr数据类型编写,您的程序调用外部API 函数实际上也必须使用LongPtr类型“ - 参见Windows API declaration VBA 64 bit。