473,409 Members | 2,063 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

I am looking for a c# function that do the same as getch()

is there any function like this?

Console.Read is not good for me because I dont want to click Enter
after reading an input.
thanks ,

Okets

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 16 '05 #1
4 1356
Console.ReadKey ()
oder
Console.ReadKey (Boolean)
Michael
"oketz1" <of**@myrealbox-dot-com.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
is there any function like this?

Console.Read is not good for me because I dont want to click Enter
after reading an input.
thanks ,

Okets

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*

Nov 16 '05 #2

There might be something but I couldn't find it when I went looking either.
I ended up using _getch(), this worked for me:

using System;
using System.Runtime.InteropServices;

[DllImport("msvcr71.dll")]
static extern int _kbhit();

[DllImport("msvcr71.dll")]
static extern int _getwch();

[DllImport("msvcr71.dll")]
static extern int _getwche();

--Richard

"oketz1" wrote:
is there any function like this?

Console.Read is not good for me because I dont want to click Enter
after reading an input.
thanks ,

Okets

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*

Nov 16 '05 #3
anyone who know ?

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 16 '05 #4
Hey,
I do it in the way similar to the way Richard did,
but I use "EntryPoint" so I can name my methods anything
I want:
<code>
using System;
using System.Runtime.InteropServices;

namespace SomeTest_CS_Console
{
/// <summary>
/// Summary description for GetChInterop.
/// </summary>
public class GetChInterop
{
[DllImport("msvcr71.dll", EntryPoint="_kbhit")]
public static extern int KbHit();

[DllImport("msvcr71.dll", EntryPoint="_getwch")]
public static extern int GetCh();

[DllImport("msvcr71.dll", EntryPoint="_getwche")]
public static extern int GetChe();
}
}
</code>

Make a managed dll once, and forget the pain in the neck...

On 18 Nov 2004 17:00:43 -0600, oketz1
<of**@myrealbox-dot-com.no-spam.invalid> wrote:
is there any function like this?

Console.Read is not good for me because I dont want to click Enter
after reading an input.
thanks ,

Okets

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*


--
Regards,
Nurchi BECHED
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Pelo GANDO | last post by:
Hi everybody, It's me again...Pelo, for an other beginner question... What the code should be in C++ to wait for a keyboard entry in order to execute the sequal of my program...
3
by: Ken | last post by:
hello, I would to know if it is possible to call an object in a function within a class. Meaning , In a class, A function X calling onto a function Y, and function Y we want one of the two...
3
by: voidstar | last post by:
Hi, I have the following problem: I use "getch" to monitor keypresses and the I use "cin" to input a string. When I type in 'y', the 'y' character appears, so I need to hit backspace before...
2
by: Shugong Wang | last post by:
getch() function is not a standard C/C++ function. Thought gcc provieds ncurses.h and a getch() function is realized, I still want to know how to realize a getch() function in standard c or c++.
9
by: Arun | last post by:
I recently came to know that using int86 function with interrupt number 22 we can identify keystrokes. I want to know whether this is in any way different from getch() function. any help on this...
2
by: vivicio047 | last post by:
please help me ! 1) i m trying to move a character using the arrow key, but dont know how to scan the arrow key. 2) form a while(1) loop i have to break, when a key is pressed(cant use getch()...
6
by: kalar | last post by:
The following loop fills an array with integers by calls to getint int main(void) { int n, array, getint(int *); for(n=0; n<SIZE && getint(&array) !=EOF; n++) ; return 0; }
43
by: shaanxxx | last post by:
if u give cordinates to programme at run time and want a line to be drawn.. how to do this in c without usin any graphics function? like x1,y1 and x2,y2 and lines should be drawn from the 1st...
2
AmberJain
by: AmberJain | last post by:
HELLO, Wikipedia defines return statement as: Now there's a C program I have coded---->
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.