You can use ReadConsoleInput to find out which keys will be pressed by the user. It can be found here: msdn: http://msdn.microsoft.com/en-us/library/windows/desktop/ms684961%28v=vs.85%29.aspx
Then you can use WriteConsole , which writes letters to the console from the current cursor position to try to autocomplete what the user types.
Then use SetConsoleCursorPosition back where the pointer was before your WriteConsole call. This will allow the user to continue typing where he left off. Just use WriteConsol to fill in the blanks to cancel autocompletion in case you make a mistake.
I donβt think that getline() will catch the letters from WriteConsole so that you can track what the user types, but also what you add using WriteConsole , or just keep track of which command he will write your thought and then call this if he presses Enter after you have suggested a command.
My last SetConsoleAttributes would be to use SetConsoleAttributes to change the color of the added row to light gray, to show the user that this is a sentence, not what he wrote.
source share