Link to home
Start Free TrialLog in
Avatar of softspot
softspot

asked on

write a new keyboard driver for software keyboard(XP)

I have created a software keyboard. I need to know how to use this to control (office) applications instead of the regular keyboard. Maybe I need to figure out how to create plugins?
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

You mean you've created an "onscreen keyboard"?  (see image below)

If so, you can use SendKeys.Send() to simulate the pressing of keys when your buttons are pushed:
http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx

osk.jpg
Avatar of softspot
softspot

ASKER

Thanks for this.Yes, it is a kind of on-screen keyboard but it does not resemble the regular keyboard at all.  I have created an application which allows limited-physical-ability users to have an alternative to the physical keyboard. When it runs, it  lets the user use a one-click action to select any key.I don't use the physical keys at all. The app cycles rapidly (and endlessly) through a series of nested loops, presenting' keys' to the user, and the user makes the selection.  I need the result of their selection, (i.e. the key-press) to act as input to whatever other application they are running (typically MS-Word etc). I have looked at SendKey.Send() but the problem is that it sends the key to the 'Active' application. This means that the keyboard application then becomes non-active. This may seem trivial but I don't see an easy solution. Also, there is the problem of finding the active application. The SetForeGroundWindow function is a possibility but I think this means  'going Native' which is not easy to manage. At least, I have never  worked outside of managed code  (in .NET) and so I don't have any experience at all in using native code.
I could give up and start over using C or Java but .NET made the development so far a real joy, and I am pushing our department to use .NET and I don't want to give up on this unless it really is not possible to find a solution.

Regards

Softspot

ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Firstly apologies for the delay in responding. I got called away to deal with other pressures. Thanks for your expert help with this problem. I have been able to use this essentially to create a solution and I have built a neat  little software 'control' app which enables me to provide the 'keyboard' input that was the initial obhjective, but which also has opened up a whole host of other possibilities. An issue which you probably know about, is that there can be a short but unpredictable delay in the transmission between the non-focused app and the currently live app. This is not a major issue for what I am doing now, but it could be for some apps, and a developer woulld need to take care with this. I speculate that it is simply XPs scheduler at work in which case there is probably not much that can be done. Anyway, that is an issue for further exploration. I learn a little more about .NET most every day and your advice and knowledge has been very much appreciated.
Regards
Softspot
Please see my comments. You have ramped my education up another notch. Much appreciated.

Softspot
Another limitation to be aware of is that the WS_EX_NOACTIVATE flag will NOT work WITHIN the SAME application.  When used on a form in the same application it no longer prevents focus from being taken.  Thus the keyboard app has to be its own executable...
Thanks. That's useful to know.