press any key to continue
-
regarding vb.net console apps... i was wondering if there was a way to determine when any key was pressed? so it can be used for instances where a 'press any key to continue' type of thing is necessary, or where a one character answer is required. Thx. ------------------------ Jordan. III
-
regarding vb.net console apps... i was wondering if there was a way to determine when any key was pressed? so it can be used for instances where a 'press any key to continue' type of thing is necessary, or where a one character answer is required. Thx. ------------------------ Jordan. III
Check into Console.Read() or Console.ReadLine(). RageInTheMachine9532
-
Check into Console.Read() or Console.ReadLine(). RageInTheMachine9532
thanks iv already worked with .read() and .readline(). .readline() gets input from the console. the user must press enter key to end the input. .read() is just like .readline but it doesnt read the full line of text the user entered, if it was even a full line at all. in both cases. the user must press the -enter- key. is there away to do it without having to press enter? ------------------------ Jordan. III
-
thanks iv already worked with .read() and .readline(). .readline() gets input from the console. the user must press enter key to end the input. .read() is just like .readline but it doesnt read the full line of text the user entered, if it was even a full line at all. in both cases. the user must press the -enter- key. is there away to do it without having to press enter? ------------------------ Jordan. III
OK. The Console class doesn't support the type of input that you want, ... yet. You'd have to look at the Win32 API to get what you want. Specifically, the GetConsole, GetStdHandle, GetConsoleMode, SetConsoleMode, FlushConsoleInputBuffer, and ReadConsoleInput functions. You'd have to write your own PressAnyKey function that, when entered into, gets the handle to the current console window, get the handle to the StdIn stream, saves the current console input mode on the stream, setups up a new mode that disables LINE INPUT, then use FluchConsoleInputBuffer to clear out any remaining keystrokes. Put up your 'Press any key to continue' prompt, then use ReadConsoleInput to get the next character in the input stream. When all that is done, then you restore the console input mode and call FlushConsoleInputBuffer to clear any remain keystrokes out. Hopefully(!), this functionality will be in .NET 2.0. RageInTheMachine9532
-
OK. The Console class doesn't support the type of input that you want, ... yet. You'd have to look at the Win32 API to get what you want. Specifically, the GetConsole, GetStdHandle, GetConsoleMode, SetConsoleMode, FlushConsoleInputBuffer, and ReadConsoleInput functions. You'd have to write your own PressAnyKey function that, when entered into, gets the handle to the current console window, get the handle to the StdIn stream, saves the current console input mode on the stream, setups up a new mode that disables LINE INPUT, then use FluchConsoleInputBuffer to clear out any remaining keystrokes. Put up your 'Press any key to continue' prompt, then use ReadConsoleInput to get the next character in the input stream. When all that is done, then you restore the console input mode and call FlushConsoleInputBuffer to clear any remain keystrokes out. Hopefully(!), this functionality will be in .NET 2.0. RageInTheMachine9532
-
Wow.. sure looks like you did some homework, either online or previously, in your head. ill try and check it out! thanks alot Dave ------------------------ Jordan. III
Most of it from memory, but a little research on MSDN for the specifics... Who knows...if I get the time, I might make a class out of it and write up a CodeProject article. :-D RageInTheMachine9532
-
Most of it from memory, but a little research on MSDN for the specifics... Who knows...if I get the time, I might make a class out of it and write up a CodeProject article. :-D RageInTheMachine9532