How to...

  • Thread starter Thread starter Jacek Jurkowski
  • Start date Start date
J

Jacek Jurkowski

Read a key from the keyboard?

While(true)
{
if(SomeReadKeyMethod() == Keys.Esc)
{
someThrow.Abort();
}
}
 
Start by making your subject related to what you are looking for. This entire
forum is generally set up for people learning how to do something or anther.

See the OnKeyPressed event for your form.
 
The problem is that i have no any form at the moment
i have to intercept the key...
 
So, do you have a console application, or a windows form app with the main
form invisible, or are you trying to write a global keyboard hook? Be as
specific with your question as you can.

The more people have to guess, the less likely they are to help.
 
It's a win forms application and Yes, i do have a invisible
main form but i want to have a global hook independent
to the main form.

From the main application i start a new thread with some loop
inside without any form displayed. I want to break that loop
when user presses ESC button...
 
It's a win forms application and Yes, i do have a invisible
main form but i want to have a global hook independent
to the main form.

From the main application i start a new thread with some loop
inside without any form displayed. I want to break that loop
when user presses ESC button...

So the user could be off in any other application and press Esc for some
perfectly reasonable purpose in that application and you want YOUR process
to stop?
 
I'm guessing your application would be used to capture a screen session in
Windows or something like that, and you would terminate the session by
pressing the ESC key.

I'm guessing you're going to have to get a handle to the desktop, then
process characters that the desktop receives.

I'm not sure how to do that, though. If using C#, you'll almost certainly
need to P/Invoke some of the Windows APIs.
 
Back
Top