Okay, I don't know how exactly I can explain this, but I've been searching here and there, and didn't find what I wanted.
Do you know how can I allow pressing some keys on the keyboard in C++? I mean, when you are in the console and you are only allowed to press numbers before pressing enter, for example.
It looks like there may be some OS specific ways of doing this, but I'm not sure how effective they are. It would be easier to let the user type whatever they want, and just ignore everything you don't want, like spaces.
Yeah, I know that it's easier that way, but, that's not what I need to do. And I also know that using "GetAsyncKeyState" and "SetKeyboardState" I could do that, but I don't understand how to.
then what you want to do is enable unbuffered input and simply ignore keys other than 0 through 9 (and break keys else your users will hate you).
You can SetConsoleMode() to do this on Windows. It isn't quite as simple on *nix (but for a different reason than you may think -- you must take care to handle input in a much more involved way than you would otherwise).
Another useful possibility is to use NCurses/PDCurses.
Keep in mind that either option will defeat the general use of your program by requiring a human to be present to use it.
If you are trying to mess with other running processes then I won't help. It can be done, mind you, but you shouldn't.