Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing an on-screen keyboard for my web browser. I want to show the keyboard when the text cursor is visible. Web Browser is the main Form, while the Keyboard is the secondary Form. Please help.

Earlier, I am able to send data from keyboard to textbox in the main form, but I want it to be generic for all the textboxes of websites or browser itself. I want it to show whenever a text cursor is visible.
Posted
Comments
Sergey Alexandrovich Kryukov 14-Mar-15 17:29pm    
If has nothing to do with ASP.NET.
None of the ways you listed is what you really need. You need to send input events to any focused control.
I'm just curious: how did you send "keyboard data" to one control so far?
—SA
Member 11485559 14-Mar-15 17:42pm    
I want to show keyboard whenever a text cursor is focused and then send input.
Right now, I'm just creating a new keyboard form and showing it whenever I click on AddressBarTextBox and sending just strings of characters pressed on the keyboards.

1 solution

First of all, please see a comment to the question.

"To be generic", instead of sending any messages to any controls at all, you can generate the input events on low level, as it is done by the keyboard (and mouse, by the way) drivers. Then the input will be dispatched where they belong. In case of keyboard, to the control where the keyboard focus is, which is one control per whole desktop.

This can be achieved by using raw Windows API SendInput:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310%28v=vs.85%29.aspx[^].

It will require using P/Invoke, but this is already done for you: http://www.pinvoke.net/default.aspx/user32.sendinput[^].

You will need to solve some problems though. First of all, you don't want the keys of the virtual keyboards, which are also controls (buttons or anything else), not to grab the focus, and the virtual keyboard to grab activation. You don't really need to solve the second problem: better design could be using only one form, and then the control could be a panel (removable, collapsible, whatever), not a form. And the keys can be simply made non-focusable; after all, it would be pretty much pointless to use a keyboard to press virtual keyboard keys. However, if you still have to solve any of the problems mentioned above, please see my past answers:
Application focus getting and losing[^],
and also, just in case: Creating a Virtual Keyboard[^],
Programming on BACKSPACE button[^],
Application focus getting and losing[^].

—SA
 
Share this answer
 
Comments
Member 11485559 14-Mar-15 17:49pm    
Thank you so much for your response, I am looking forward to it.
Sergey Alexandrovich Kryukov 14-Mar-15 18:02pm    
Sure. When you get it and see it can work for you (it certainly should), please accept the answer formally.
In all cases, your follow-up questions will be welcome.

Note that if you really want to limit your virtual keyboard functionality by the WebBrowser control and/or other control on your own form, your problem is much simpler. If you want to develop a system-wide (desktop-wide) keyboard, you will certainly have to do all the precautions I mentioned.

—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900