API声明和函数如下:
'The GetQueueStatus function indicates the type of messages found in the calling thread's message queue. Here are the flags that GetQueueStatus uses :
'QS_ALLEVENTS An input, WM_TIMER, WM_PAINT, WM_HOTKEY, or posted message is in the queue.
'QS_ALLINPUT Any message is in the queue.
'QS_ALLPOSTMESSAGE A posted message (other than those listed here) is in the queue.
'QS_HOTKEY A WM_HOTKEY message is in the queue.
'QS_INPUT An input message is in the queue.
'QS_KEY A WM_KEYUP, WM_KEYDOWN, WM_SYSKEYUP, or WM_SYSKEYDOWN message is in the queue.
'QS_MOUSE A WM_MOUSEMOVE message or mouse-button message (WM_LBUTTONUP, WM_RBUTTONDOWN, and so on).
'QS_MOUSEBUTTON A mouse-button message (WM_LBUTTONUP, WM_RBUTTONDOWN, and so on).
'
'QS_MOUSEMOVE A WM_MOUSEMOVE message is in the queue.
'QS_PAINT A WM_PAINT message is in the queue.
'QS_POSTMESSAGE A posted message (other than those listed here) is in the queue.
'QS_SENDMESSAGE A message sent by another thread or application is in the queue.
'QS_TIMER A WM_TIMER message is in the queue.
'
'(I believe that GetInputState() is a GetQueueStatus(QS_HOTKEY Or QS_KEY Or QS_MOUSEBUTTON))
'
'With these constants you can create your own GetInputState function that fits your needs. For example you can create a custom function that issues DoEvents when it'll detects not only a Keyboard or Mouse
'Key input, but also a WM_PAINT signal.
'Why 's that? 'cause in your loop you might need to update the screen so you must let your custom function process the specific signal.
'Look at this :
Private Const QS_HOTKEY = &H80
Private Const QS_KEY = &H1
Private Const QS_MOUSEBUTTON = &H4
Private Const QS_MOUSEMOVE = &H2
Private Const QS_PAINT = &H20
Private Const QS_POSTMESSAGE = &H8
Private Const QS_SENDMESSAGE = &H40
Private Const QS_TIMER = &H10
Private Const QS_ALLINPUT = (QS_SENDMESSAGE Or QS_PAINT Or QS_TIMER Or QS_POSTMESSAGE Or QS_MOUSEBUTTON Or QS_MOUSEMOVE Or QS_HOTKEY Or QS_KEY)
Private Const QS_MOUSE = (QS_MOUSEMOVE Or QS_MOUSEBUTTON)
Private Const QS_INPUT = (QS_MOUSE Or QS_KEY)
Private Const QS_ALLEVENTS = (QS_INPUT Or QS_POSTMESSAGE Or QS_TIMER Or QS_PAINT Or QS_HOTKEY)
Private Declare Function GetQueueStatus Lib "user32" (ByVal qsFlags As Long) As Long
Public Function cGetInputState() As Boolean
Dim o_lngRet As Long
o_lngRet = GetQueueStatus(QS_HOTKEY Or QS_KEY Or QS_MOUSEBUTTON Or QS_PAINT)