I created a keypad app that stays on top, but does not take the focus so that on a touch screen it will forward whatever keys you press to the active application via SendKeys.
It works perfectly with every application I have tried it with... except, of course, for the one I actually need it to work with which is a Point Of Sale application. The POS application lets the user type in item codes on the keyboard but it doesn't have a good keypad for touchscreens so that's why I'm trying to create an external one for it (since I don't have access to the POS application code).
It actually does work when you first try it, but then it's pretty sporadic. Using the keyboard directly always works, so I'm not sure why SendKeys only works sometimes with this application. I've tried implementing it several ways... sending the keys as they are pressed, sending them altogether when the user presses the enter button on the keypad, copying the keys to the clipboard and then using send keys to do a Ctl-V and then Enter.
What other options do I have to simulate a key press to another application? SendKeys doesn't seem to perfectly simulate key presses, so is there a lower level mechanism I can tap into?
I should mention that when it doesn't work, what happens is that I get a beep from the POS application as though I'd pressed an invalid key. So it's not that it isn't getting some kind of input but clearly it isn't getting the key I'm sending it the same way it would from an actual keyboard.
I found this Windows Input Simulator: https://inputsimulator.codeplex.com/
Super easy to use and way, way, way better than SendKeys. And as a bonus, in addition to letting you simulate input, it also lets you set low level keyboard/mouse hooks.