The Almighty C# Console Mode
ErrrR grumble grumble.. C# has crapy console more classes.
Is any good function that checks to see if there has been a key pressed? Or that checks to see if any keypresses are in the buffer?
The function must not block if there is no keypresses.
I don't thnik I can use windows.froms events to keypresses, becouse it's a console app there are no controls to capture it on.
Any help?
[Edited by - DarkSol on September 1, 2004 7:55:19 PM]
Anyone got any ideas? googled for help.. but it's all how to do it with windows.forms nothing on the console.
Ahhh.. of couse. must be something I did to it.
thanks afterburn. not to find a what I did to make it block.
thanks afterburn. not to find a what I did to make it block.
//got to be this thats caseing the problem.[DllImport("kernel32.dll", EntryPoint="SetConsoleMode", SetLastError=true, CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]private static extern int SetConsoleMode(IntPtr hConsoleHandle, int dwMode);[DllImport("kernel32.dll", EntryPoint="GetConsoleMode", SetLastError=true, CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]private static extern int GetConsoleMode(IntPtr hConsoleHandle, ref int dwMode);const int ENABLE_LINE_INPUT = 2;const int ENABLE_ECHO_INPUT = 4;const int STD_INPUT = 3;IntPtr hStdIn = new IntPtr(STD_INPUT);int mode=0;GetConsoleMode(hStdIn, ref mode);mode = (mode & ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT));SetConsoleMode(hStdIn, mode);int s="-this is the default blank";//here is my reads = Console.Read();
I used Visual C# Express Beta on a friends computer(thus using C# 2.0 and the .NET Framework 2.0 beta). The 2.0 version of the .NET framework has a lot of nice functions for console support. Colors, etc. Although to use it you'll have to wait until 2.0 is release final before you distribute your app. I don't have the beta's install on my computer because I have visual studio 2003 and everything working good and I don't want to mess it up somehow.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement