Hello all,
I tried to run this code which records Mouse events but it seemed mouse events couldnt be captured on my computer, mouse clicks , scroll wheels, clicks...
Only Keyboard events were captured correctly, sometimes , after I hit Ctrl+F5 to run compiled prog , mouse events shows 1 and that's it.
I use C++ Express, hope you guys could help me.
Thanks.
Close, but before the loop, and don't lose other modes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
int main()
{
...
DWORD consoleMode;
if (!GetConsoleMode( hIn, &consoleMode ))
{
// not connected to a console!
}
SetConsoleMode( hIn, consoleMode | ENABLE_MOUSE_INPUT );
while (Continue)
{
...
}
SetConsoleMode( hIn, consoleMode );
return 0;
}
There is one other thing that MS neglects to warn you about. The "QuickEdit" mode option on your console must not be enabled. Yes, I know... stupid. I don't know how to disable it programmatically. (I'll figure it out someday though --probably long after it is obsolete. :-P )
To find out, choose "Properties" from the console's system menu (right-click the icon on the console titlebar) and examine the lower-right side of the "Options" tab.
As long as QuickEdit mode is enabled, your console applications will not receive mouse events. Alas.