You’ll need to use the *ConsoleInput
family of methods (peek, read, etc). These operate on the console’s input buffer, which includes keyboard and mouse events. The general strategy is:
- wait on the console’s input buffer handle (
ReadConsoleInput
) - determine the number of waiting events (
lpNumberOfEventsRead
) - handle them as you see fit (i.e.
MOUSE_EVENT
andMOUSE_EVENT_RECORD
)
You’ll have to indicate that you want to retrieve mouse input using SetConsoleMode
first though, as illustrated in this MSDN article.