Use SetWindowHookEx() to create a KeyboardHook to ensure all keys sent by keybd_event() are received.
Pseudo-code:
Function KeybdHook(key, ...)
For iKey = 1 to len(keys)
if not keys(iKey).received then
if key.code = keys(iKey).code then
key.received = true
exit for
end if
exit for
end if
next
KeybdHook = CallNextHookEx(...)
End Function
Function SendKeysEvent(..., Optional bWaitForRetrieval as boolean)
if bWaitForRetrieval then iHook = SetWindowHookEx(ActiveWnd, WH_KEYBOARD, AddressOf KeybdHook)
For iKey = 1 to len(keys)
keybd_event(keys(iKey))
next
if bWaitForRetrieval then
While not keys(len(keys)).received
DoEvents
Wend
Call ClearWindowHookEx(iHook)
end if
End Function
Use
SetWindowHookEx()
to create a KeyboardHook to ensure all keys sent by keybd_event() are received.Pseudo-code:
See also: