"On screen keyboard" user control
-
Hi, I am trying to write a custom user control which is a "On screen keyboard" used for touch screen monitor. So when user press a key on the "On screen keyboard", the program knows as if the key on the keyboard is pressed. What should I have in KeyPress event for each keyboard character? or there are some other ways to do it? Also, how to loop through all key chars on keyboard? Thank!!!!
-
Hi, I am trying to write a custom user control which is a "On screen keyboard" used for touch screen monitor. So when user press a key on the "On screen keyboard", the program knows as if the key on the keyboard is pressed. What should I have in KeyPress event for each keyboard character? or there are some other ways to do it? Also, how to loop through all key chars on keyboard? Thank!!!!
Alan Zhao wrote: What should I have in KeyPress event for each keyboard character? How complete a keyboard are you emulating? Anyways, the truly simple way of figuring this out is try it with a keyboard! However, the right answer (I think) is that you'll want to inject the key-down and key-up messages into the Windows message queue. These keycodes are different (I think) from what you get with KeyPress. The reason for doing it this way is that any control can then receive the key up/down messages from your (I suppose) background thread. It's probably a bit more complicated than I've described, but that's the approach I would start with. Marc Microsoft MVP, Visual C# MyXaml MyXaml Blog
-
Alan Zhao wrote: What should I have in KeyPress event for each keyboard character? How complete a keyboard are you emulating? Anyways, the truly simple way of figuring this out is try it with a keyboard! However, the right answer (I think) is that you'll want to inject the key-down and key-up messages into the Windows message queue. These keycodes are different (I think) from what you get with KeyPress. The reason for doing it this way is that any control can then receive the key up/down messages from your (I suppose) background thread. It's probably a bit more complicated than I've described, but that's the approach I would start with. Marc Microsoft MVP, Visual C# MyXaml MyXaml Blog
How do you send the messages to Windows message queue and what's Windows message queue? I am emulating a keyboard with all letters, digits, and a enter key. Correction: What should I have in MouseDown or Click event b/c the keys are clicked by touch on the screen.
-
Alan Zhao wrote: What should I have in KeyPress event for each keyboard character? How complete a keyboard are you emulating? Anyways, the truly simple way of figuring this out is try it with a keyboard! However, the right answer (I think) is that you'll want to inject the key-down and key-up messages into the Windows message queue. These keycodes are different (I think) from what you get with KeyPress. The reason for doing it this way is that any control can then receive the key up/down messages from your (I suppose) background thread. It's probably a bit more complicated than I've described, but that's the approach I would start with. Marc Microsoft MVP, Visual C# MyXaml MyXaml Blog
Actually, they are the same, fortunately. This saves work of having to define a separate enum to send keyboard messages and P/Invoke related functions. This is true for the .NET FCL as well - it saves them work, too.
Microsoft MVP, Visual C# My Articles
-
How do you send the messages to Windows message queue and what's Windows message queue? I am emulating a keyboard with all letters, digits, and a enter key. Correction: What should I have in MouseDown or Click event b/c the keys are clicked by touch on the screen.
The Windows message queue is the heart of the Windows operating system, something you really should understand before attempting such a project. The message queue is just what it (should) sounds like: a queue for messages. A message contains data about the destination window (every control and dialog in Windows is a window), the message you want to send, and to parameters that can point to anything and be used for whatever you like (although the pre-defined Windows messages do define what those should contain in the Platform SDK on MSDN Online[^]. You should read about Windowing[^] to gain a better understanding. You can also P/Invoke
SendInput
, which is defined and discussed in the function reference section of another section you should read and understand, Keyboard Input[^]. If you're not familiar with P/Invoke, you should learn[^], but you could also just take a look at http://pinvoke.net/default.aspx/user32.SendInput[^].Microsoft MVP, Visual C# My Articles
-
Actually, they are the same, fortunately. This saves work of having to define a separate enum to send keyboard messages and P/Invoke related functions. This is true for the .NET FCL as well - it saves them work, too.
Microsoft MVP, Visual C# My Articles
-
So how do I sent the keyboard message as if user has press the key on keyboard when he/she really touchs the mointor. Thank!
I already told you in my other reply to your thread: http://www.codeproject.com/script/comments/forums.asp?msg=830391&forumid=1649#xx830391xx[^].
Microsoft MVP, Visual C# My Articles
-
So how do I sent the keyboard message as if user has press the key on keyboard when he/she really touchs the mointor. Thank!
Alan Zhao wrote: So how do I sent the keyboard message as if user has press the key on keyboard when he/she really touchs the mointor. You'll need a worker thread monitoring the input from the touch screen. The one's I've used had an RS-232 interface that provided the x, y coordinates of where the user touched. Of course, this had to be de-jittered, tested for a sufficiently long period of touch, and mapped to whatever graphics I had on the screen. Oh yes, and there's a calibration process involved to. Sounds like you're in some deep water. :) Marc Microsoft MVP, Visual C# MyXaml MyXaml Blog
-
Alan Zhao wrote: So how do I sent the keyboard message as if user has press the key on keyboard when he/she really touchs the mointor. You'll need a worker thread monitoring the input from the touch screen. The one's I've used had an RS-232 interface that provided the x, y coordinates of where the user touched. Of course, this had to be de-jittered, tested for a sufficiently long period of touch, and mapped to whatever graphics I had on the screen. Oh yes, and there's a calibration process involved to. Sounds like you're in some deep water. :) Marc Microsoft MVP, Visual C# MyXaml MyXaml Blog
Hi, thanks for the help, but I didn't expect it to be this complicated.;) This on-screen keyboard is written in Visual C#, so each Button represents a key. Therefore, when the user touch the button on the screen, it's like you click the button using mouse. So the SomeKey_Click() event fired. My problem is how do I tell system that SomeKey is pressed without physically type the key. Thanks again!
-
Hi, thanks for the help, but I didn't expect it to be this complicated.;) This on-screen keyboard is written in Visual C#, so each Button represents a key. Therefore, when the user touch the button on the screen, it's like you click the button using mouse. So the SomeKey_Click() event fired. My problem is how do I tell system that SomeKey is pressed without physically type the key. Thanks again!
I'm a bit confused as to the state of affairs. Alan Zhao wrote: This on-screen keyboard is written in Visual C#, so each Button represents a key. Is that part working already? Alan Zhao wrote: Therefore, when the user touch the button on the screen, it's like you click the button using mouse. Does that part work too? Alan Zhao wrote: So the SomeKey_Click() event fired. And each button on the screen has an event associated with it, so that when the user touches the screen, the button's Click event fires? Alan Zhao wrote: My problem is how do I tell system that SomeKey is pressed without physically type the key. Heath already answered that question, I thought. Marc Microsoft MVP, Visual C# MyXaml MyXaml Blog